DAX Function Guide

CONTAINS
Empty image or helper icon

Sam McKay

CEO & Founder

How does the CONTAINS work?
The CONTAINS function returns true if the values for the specified columns exist or are contained, in those columns; otherwise, the function returns false.
CONTAINS Formula Syntax

CONTAINS (
     <table>, <columnName>, <value> [, <columnName>, <value>]…
)

How do you use the CONTAINS?

This function is used within another function to search for a character or string. It returns a value of true if found, and false if not found.

Related Blog Posts

Loading

Considerations when using the CONTAINS?
  • The arguments columnName and value must come in pairs; otherwise an error is returned.
  • columnName must belong to the specified table, or to a table that is related to table.
  • If columnName refers to a column in a related table then it must be fully qualified; otherwise, an error is returned.
  • Related Video Tutorials

    Loading

    Formula examples using the CONTAINS

    =CONTAINS(InternetSales, [ProductKey], 214, [CustomerKey], 11185)

    COUNTROWS ( FILTER ( table, columnName = value ) ) > 0

    CALCULATE ( [measure], FILTER ( ALL ( targetTable[targetColumn] ), CONTAINS ( VALUES ( sourceTable[sourceColumn] ), sourceTable[sourceColumn], targetTable[targetColumn] ) ) )

    Related Courses

    Loading