CONTAINS

Updated on

CONTAINS is a DAX function that returns TRUE if there exists at least one row where all specified columns have the specified values.

Syntax

CONTAINS(
   Table,
   [ ColumnName, ... ],
   [ Value, ... ]
)
Argument Properties Description
Table The table to test.
ColumnName Repeatable A column in the input table or in a related table.
Value Repeatable A scalar expression to look for in the column.

Return Values

A value of TRUE if each specified value can be found in the corresponding columnName, or are contained, in those columns; otherwise, the function returns FALSE.

Remarks

  • 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.

  • This function is not supported for use in DirectQuery mode when used in calculated columns or row-level security (RLS) rules.

Example

The following example creates a measure that tells you whether there were any Internet sales of product 214 and to customer 11185 at the same time.

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

Other functions related to CONTAINS are:

Contribute » | Contributors: Rick de Groot
Microsoft documentation: https://learn.microsoft.com/en-us/dax/contains-function-dax

2023-2024 © BI Gorilla. All rights are reserved. Information from Microsoft docs is property of Microsoft Corp. | Privacy Policy