CONTAINSROW
Whether a table has a row equal to the values given (as IN does).
Group: Information. Compatible with DAX.
Syntax
CONTAINSROW ( <table>, <value> [, <value>] … )
| Parameter | Type | Description |
|---|---|---|
table | Table | The rows to search: a table expression, or a list of values written in braces. |
value | Value repeatable | One value for each column of the table, in the order of its columns. |
Returns
Boolean. TRUE when some row equals the values given, column by column; FALSE otherwise.
Remarks
- Give as many values as the table has columns: one too few or too many is an error.
Products[Product] IN { "Pils", "IPA" }is the same test written as an operator:CONTAINSROW ( { "Pils", "IPA" }, Products[Product] ).- The comparison is strict: a blank equals only a blank, not 0 and not empty text. Text is compared without regard to case.
- There is no NOT IN: put
NOTbefore the whole call, or before theINtest.
Examples
A row of two values
The order of the values follows the table's columns: product, then liters.
EVALUATE
VAR Orders =
DATATABLE (
"Product", STRING, "Liters", INTEGER,
{ { "Pils", 120 }, { "IPA", 80 }, { "Stout", BLANK () } }
)
RETURN
ROW (
"IPA, 80", CONTAINSROW ( Orders, "IPA", 80 ),
"Lower case", CONTAINSROW ( Orders, "ipa", 80 ),
"Stout, blank", CONTAINSROW ( Orders, "Stout", BLANK () ),
"Stout, 0", CONTAINSROW ( Orders, "Stout", 0 )
)
| IPA, 80 | Lower case | Stout, blank | Stout, 0 |
|---|---|---|---|
| TRUE | TRUE | TRUE | FALSE |
Keeping the products of a list
The same rows as FILTER ( Products, Products[Product] IN { "Pils", "IPA" } ).
EVALUATE
FILTER ( Products, CONTAINSROW ( { "Pils", "IPA" }, Products[Product] ) )
ORDER BY Products[Product]
| Products[Product] | Products[Category] | Products[Price per liter] |
|---|---|---|
| IPA | Beer | 64 |
| Pils | Beer | 38 |