Table.ContainsAny

Table

Returns true if the table contains any of the specified rows.

Examples on this page use shared sample tables. View them to understand the input data before reading the examples below.

Syntax

Table.ContainsAny(table as table, rows as list, optional equationCriteria as any) as logical

Parameters

NameTypeRequiredDescription
tabletableYesThe table to search.
rowslistYesA list of records, at least one of which must exist in the table.
equationCriteriaanyNoOptional. Column name(s) or comparer to control which fields are compared.

Return Value

logicaltrue if at least one record in the rows list has a matching row in the table; false otherwise.

Remarks

Table.ContainsAny returns true if at least one record from the rows list has a matching row in the table. It is the logical OR of multiple Table.Contains checks: evaluation stops as soon as a match is found. If no record in the list matches any row in the table, it returns false.

This is the complement of Table.ContainsAll. Use Table.ContainsAny when you want to check whether at least one of several candidate values is present in a dataset — for example, verifying that at least one "high-priority" flag appears before sending an alert, or determining whether any East or North region orders exist in a filtered dataset.

Like Table.Contains, the equationCriteria parameter can restrict the comparison to specific columns. An empty rows list returns false. This function does not fold to data sources.

Examples

Example 1: Check whether any East or North region orders exist

let
    Sales = #table(
        {"OrderID", "CustomerName", "Region"},
        {{1,"Alice","East"},{2,"Bob","West"},{3,"Charlie","East"},{4,"Alice","North"}}
    ),
    TargetRegions = {[Region = "North"], [Region = "South"]}
in
    Table.ContainsAny(Sales, TargetRegions, "Region")
Result
Result
1TRUE

Example 2: None of the candidates are present

let
    Products = #table(
        {"Category"},
        {{"Widgets"},{"Gadgets"},{"Misc"}}
    ),
    SearchCategories = {[Category = "Electronics"], [Category = "Furniture"]}
in
    Table.ContainsAny(Products, SearchCategories, "Category")
Result
Result
1FALSE

Example 3: Match on a specific customer with full record comparison

let
    Sales = #table(
        {"CustomerName", "Product"},
        {{"Alice","Widget A"},{"Bob","Gadget B"},{"Diana","Widget C"}}
    ),
    Candidates = {[CustomerName = "Diana", Product = "Widget C"], [CustomerName = "Eve", Product = "Gadget D"]}
in
    Table.ContainsAny(Sales, Candidates)
Result
Result
1TRUE

Compatibility

Power BI Desktop Power BI Service Excel Desktop Excel Online Dataflows Fabric Notebooks