Power QueryExercises

List.Contains

List function · By Tahir Nas · Examples run in our simulator · Published · Updated

Tests whether a list contains a value.

When to use it

Use it to test membership: keep rows whose value appears in an allowed list, or flag values that appear in another table's column. For a few values it reads better than a chain of or conditions, and the list can come from a parameter or another query.

Syntax

List.Contains(list as list, value as any, optional equationCriteria as any) as logical

Returns

true or false.

Example

List.Contains({"Kite", "Reel"}, "Reel")

Result

true

Example: flag rows found in another table

Comparing against another table's column marks matches without a merge.

Table.AddColumn(#table({"Cust"}, {{"A"}, {"B"}}), "Blocked", each List.Contains(#table({"Cust"}, {{"B"}})[Cust], [Cust]), type logical)

Result

CustBlocked
Afalse
Btrue

Both results are produced by the Power Query Exercises simulator, an independent implementation of a documented subset of M, and checked on every build.

Good to know

Common mistakes

Exercises that use List.Contains

Learn more

Related functions

Official documentation: List.Contains on Microsoft Learn.