CONTAINS Function (DAX)
How does the CONTAINS function (DAX) 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 function?
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
Related Support Forum Posts
How to simplify a long formula like this?
Multi Criteria, IF and contains
DAX Measure That Contains Part of String
Considerations when using the CONTAINS function
- 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
Formula examples using the CONTAINS function
=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] ) ) )