Article

DAX Language - CONTAINS Function


A-Badde | Posted on May 09, 20

CONTAINS Function

 Description:

CONTAINS function checks if there exists at least one row where all columns have specified values.

 Return Value:

CONTAINS returns a boolean value, TRUE if each specified value can be found in the corresponding columnName, or are contained, in those columns; otherwise, it returns FALSE.

 Syntax:

CONTAINS(<Table>,<ColumnName>,<Value> [,<ColumnName>,<Value> [, … ] ])
  • Description of the parameters:

PARAMETER

DESCRIPTION

Table

DAX expression that returns a table of data to test

ColumnName

Name of an existing column in the input table or in a related table.

Value

DAX expression that returns a single scalar value to look for in the column

 

 Example:

An example of the CONTAINS function is to check for the resistance of a value in a column.

So, let's create a measure that checks if the 'ProductSubCategory' column contains the value "Speakers". To do this, we will use the following formula

CONTAINSMeasure = 
CONTAINS(
    ProductSubcategory,
    ProductSubcategory[ProductSubcategory],
    "Speakers"
)

 Note that:

  • columnName must belong to the specified table, or to a table that is related to table.
  • The arguments columnName and value must come in pairs; otherwise an error is returned.

 

Related Video:

 


(0) Comments

There is no comment

Leave a Comment

Your email address will not be published. Required fields are marked *

Add to favorite
Categories
Recent Posts
DAX Language - CONTAINS Function
A-Badde | May 09, 20

The CONTAINS function returns a boolean value, TRUE if each ...Read More


DAX Language - RANKX Function
A-Badde | May 05, 20

The RANKX function returns a single integer value that repre...Read More


DAX Language - AND and OR Functions
A-Badde | April 10, 20

AND/OR functions check whether all arguments are TRUE or one...Read More


DAX Language - Variables in DAX
A-Badde | April 10, 20

Use Var keyword to store the result of an expression as a na...Read More