List.Contains
Whether a value is among a list's items.
Group: List. Power Query M has it too: a query that uses it is written as in Power BI.
Syntax
List.Contains(list as list, value as any, optional equationCriteria as any) as logical
| Parameter | Type | Description |
|---|---|---|
list | list | The list to look in. |
value | any | The value to look for. |
equationCriteria | any optional | How two values count as equal: a comparer such as Comparer.OrdinalIgnoreCase, or a function of one value that gives the key to compare. |
Returns
logical. true when some item equals the value.
Remarks
- Without equationCriteria, text is compared exactly, capitals and all.
Examples
Is Bergen one of the shops?
List.Contains({"Oslo", "Bergen", "Trondheim"}, "Bergen")
true
Capitals matter by default
List.Contains({"Oslo", "Bergen", "Trondheim"}, "bergen")
false
Ignoring capitals
List.Contains({"Oslo", "Bergen", "Trondheim"}, "bergen", Comparer.OrdinalIgnoreCase)
true
Related functions
List.ContainsAny, List.ContainsAll, List.PositionOf, Text.Contains.