OpenBI Docs Buy

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
ParameterTypeDescription
listlistThe list to look in.
valueanyThe value to look for.
equationCriteriaany
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

List.ContainsAny, List.ContainsAll, List.PositionOf, Text.Contains.

Last updated · OpenBI Studio 0.3.79