Table.Contains is a Power Query M function that checks if a specified record appears as a row in the table, with an optional parameter to control comparison between rows. The function returns a logical value indicating the presence of the record.
Compatible with: Power BI Service Power BI Desktop Excel Microsoft 365
Syntax
Table.Contains(
table as table,
row as record,
optional equationCriteria as any,
) as logical
| Argument | Attribute | Description |
|---|---|---|
| table | The table to check. | |
| row | The row values in to look for specified as a record value. | |
| equationCriteria | optional | Uses Comparer Functions to determine how values are equated during operations. Options include Comparer.Ordinal for exact case-sensitive matching, Comparer.OrdinalIgnoreCase for case-insensitive matching, and Comparer.FromCulture for culture-specific comparisons. |
Description
Table.Contains checks if a specified record, row, appears as a row in table. An optional equationCriteria can be used for row comparison.
Examples
Determine if the table contains the row.
// Output: true
Table.Contains(
Table.FromRecords( {
[CustomerID = 1, Name = "Bob", Phone = "123-4567"],
[CustomerID = 2, Name = "Jim", Phone = "987-6543"],
[CustomerID = 3, Name = "Paul", Phone = "543-7890"],
[CustomerID = 4, Name = "Ringo", Phone = "232-1550"]
} ),
[Name = "Bob"]
)
Determine if the table contains the row.
// Output: false
Table.Contains(
Table.FromRecords( {
[CustomerID = 1, Name = "Bob", Phone = "123-4567"],
[CustomerID = 2, Name = "Jim", Phone = "987-6543"],
[CustomerID = 3, Name = "Paul", Phone = "543-7890"],
[CustomerID = 4, Name = "Ringo", Phone = "232-1550"]
} ),
[Name = "Ted"]
)
Determine if the table contains the row comparing only the column [Name].
// Output: true
Table.Contains(
Table.FromRecords( {
[CustomerID = 1, Name = "Bob", Phone = "123-4567"],
[CustomerID = 2, Name = "Jim", Phone = "987-6543"],
[CustomerID = 3, Name = "Paul", Phone = "543-7890"],
[CustomerID = 4, Name = "Ringo", Phone = "232-1550"]
} ),
[CustomerID = 4, Name = "Bob"],
"Name"
)
Related articles
Learn more about Table.Contains in the following articles:
- The IN Operator in M / Power Query
This article describes the IN operator in Power Query. It checks whether a value equals one of many and is meant to simplify your code. » Read more
Related functions
Other functions related to Table.Contains are:
2023-2026 © BI Gorilla. All rights are reserved. Information from Microsoft docs is property of Microsoft Corp. | Privacy Policy