Article

DAX Language - CONTAINS Function

DAX Language - CONTAINS Function


A.Baddane | Posted on May 09, 21

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
Add to favorite
Categories
Recent Posts
Filter column based on a list in Power Query
A.Baddane | April 05, 23

Sometimes when you work within power query, you need to filt...Read More


Use HTML in Power BI - Part 2
A.Baddane | July 05, 22

In the first blog post about using HTML in Power BI Desktop,...Read More


Use HTML in Power BI
A.Baddane | Feb. 21, 22

In this blog post, I will show you how to use HTML to create...Read More


Covid-19 Report
A.Baddane | Nov. 23, 21

The COVID-19 pandemic, also known as the coronavirus pandemi...Read More