Power QueryExercises

List.Distinct

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

Removes duplicate values from a list.

When to use it

Use it to get the unique values of a list or column, for example the pivot values for Table.Pivot, a count of distinct customers with List.Count, or the options for a parameter list.

Syntax

List.Distinct(list as list, optional equationCriteria as any) as list

Returns

A list of distinct values in first-seen order.

Example

List.Count(List.Distinct({"Kite", "Reel", "Kite"}))

Result

2

Example: distinct values for a pivot

The distinct values of a column, joined here so you can read them; passed to Table.Pivot, they make new categories become columns automatically.

Text.Combine(List.Distinct(#table({"Region", "Rep", "Amount"}, {{"North", "Ana", 120}, {"South", "Bo", 80}, {"North", "Cy", 200}, {"South", "Ana", 50}})[Region]), ", ")

Result

North, South

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.Distinct

Learn more

Related functions

Official documentation: List.Distinct on Microsoft Learn.