List.ContainsAny

Updated on

List.ContainsAny is a Power Query M function that checks if a given list includes any of the values from another list, with optional equation criteria for equality testing. The function returns true if any value is found in the list and false otherwise.

Compatible with: Power BI Service Power BI Desktop Excel Microsoft 365

Syntax

List.ContainsAny(
   list as list,
   values as list,
   optional equationCriteria as any,
) as logical
ArgumentAttributeDescription
listThe list of values to check.
valuesThe values to check existence of within the list.
equationCriteriaoptionalUses 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

Indicates whether the list list includes any of the values in another list, values. Returns true if value is found in the list, false otherwise. An optional equation criteria value, equationCriteria, can be specified to control equality testing.

Examples

Find out if the list {1, 2, 3, 4, 5} contains 3 or 9.

// Output: true
List.ContainsAny( {1, 2, 3, 4, 5}, {3, 9} )

Find out if the list {1, 2, 3, 4, 5} contains 6 or 7.

// Output: false
List.ContainsAny( {1, 2, 3, 4, 5}, {6, 7} )

Learn more about List.ContainsAny in the following articles:

Other functions related to List.ContainsAny are:

BI Gorilla Youtube Channel

Contribute » | Contributors: Rick de Groot
Microsoft documentation: https://learn.microsoft.com/en-us/powerquery-m/list-containsany