CONTAINS DAX Function in Power BI

The CONTAINS DAX function returns true if values for all referred columns exist, or are contained, in those columns; otherwise, the function returns false.

DAX Syntax CONTAINS(table, columnName, value[, columnName, value]…)

The function has the following parameters:
• table: Any DAX expression that returns a table of data.
• columnName: The name of an existing column, using standard DAX syntax. It cannot be an expression.
• value: Any DAX expression that returns a single scalar value, that is to be sought in columnName. The expression is to be evaluated exactly once and before it is passed to the argument list.

Example: For the demonstration of the CONTAINS dax function, let’s use the following data.

CONTAINS dax function in Power BI

Let’s create a measure which tells us whether there is any Name Esha and Marks 10 at the same time.

DAX

CONTAINS Measure = CONTAINS(Students, Students[Name], "Esha", Students[Marks], 10)

The output of the above dax function returns False as Name is Esha but Marks is 100 instead of 10.

CONTAINS dax function in Power BI

Let’s modify the measure.

DAX

CONTAINS Measure = CONTAINS(Students, Students[Name], "Esha", Students[Marks], 100)

The output of the above dax function returns True as Name is Esha and Marks is 100.

CONTAINS dax function in Power BI