OpenBI Docs Buy

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>] … )
ParameterTypeDescription
tableTableThe rows to search: a table expression, or a list of values written in braces.
valueValue
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 NOT before the whole call, or before the IN test.

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, 80Lower caseStout, blankStout, 0
TRUETRUETRUEFALSE

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]
IPABeer64
PilsBeer38

CONTAINS, FILTER, TREATAS, ISEMPTY, NOT.

Last updated · OpenBI Studio 0.3.74