Table.Contains
Tells whether a table has a row with the values of a record.
Group: Table. Power Query M has it too: a query that uses it is written as in Power BI.
Syntax
Table.Contains(table as table, row as record, optional equationCriteria as any) as logical
| Parameter | Type | Description |
|---|---|---|
table | table | The table to search. |
row | record | The values to look for, by column name; columns the record leaves out don't count. |
equationCriteria | any optional | Which columns to compare, as a name or a list of names; all of the record's fields when left out. |
Returns
logical. true when some row has every field's value.
Examples
Is a desk sold?
Table.Contains(#table({"Shop", "Product", "Units"}, {{"Oslo", "Chair", 4}, {"Bergen", "Desk", 1}, {"Oslo", "Lamp", 6}, {"Bergen", "Chair", 2}}), [Product = "Desk"])
true
A desk in Oslo?
Table.Contains(#table({"Shop", "Product", "Units"}, {{"Oslo", "Chair", 4}, {"Bergen", "Desk", 1}, {"Oslo", "Lamp", 6}, {"Bergen", "Chair", 2}}), [Shop = "Oslo", Product = "Desk"])
false
Compare one column only
The criteria say which of the record's fields count: Units is left out of the comparison.
Table.Contains(#table({"Shop", "Product", "Units"}, {{"Oslo", "Chair", 4}, {"Bergen", "Desk", 1}, {"Oslo", "Lamp", 6}, {"Bergen", "Chair", 2}}), [Product = "Lamp", Units = 99], "Product")
true
Related functions
Table.ContainsAll, Table.ContainsAny, Table.PositionOf, Table.SelectRows.