List.Distinct
A list with each value once, in the order the values first appear.
Group: List. Power Query M has it too: a query that uses it is written as in Power BI.
Syntax
List.Distinct(list as list, optional equationCriteria as any) as list
| Parameter | Type | Description |
|---|---|---|
list | list | The list. |
equationCriteria | any optional | How two values count as equal: a comparer such as Comparer.OrdinalIgnoreCase, or a key function. |
Returns
list. The first occurrence of each value.
Examples
Shops that had sales
List.Distinct({"Oslo", "Bergen", "Oslo", "Tromsø", "Bergen"})
{"Oslo", "Bergen", "Tromsø"}
Ignoring capitals
List.Distinct({"Oslo", "OSLO", "Bergen"}, Comparer.OrdinalIgnoreCase)
{"Oslo", "Bergen"}
The first spelling is the one kept.