List.ContainsAny

List

Returns true if a list contains any of the values in another list.

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

Syntax

List.ContainsAny(list as list, values as list, optional equationCriteria as any) as logical

Parameters

NameTypeRequiredDescription
listlistYesThe list to search.
valueslistYesThe list of values to check for.
equationCriteriaanyNoA comparer function for custom equality testing.

Return Value

logicaltrue if any value from the second list is found in the first list.

Remarks

List.ContainsAny returns true if at least one value from the second list appears in the first list. This is useful for checking membership against multiple possible values at once.

Examples

Example 1: Check for target categories

let
    Categories = List.Distinct(Table.Column(Sales, "Category")),
    HasGadgets = List.ContainsAny(Categories, {"Gadgets", "Electronics"})
in
    #table({"HasGadgets"}, {{HasGadgets}})
Result
HasGadgets
1TRUE

Compatibility

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