Table.Distinct

Table

Removes duplicate rows from a table based on all columns or specified criteria.

Examples on this page use shared sample tables. View them to understand the input data before reading the examples below.

Syntax

Table.Distinct(table as table, optional equationCriteria as any) as table

Parameters

NameTypeRequiredDescription
tabletableYesThe table to remove duplicate rows from.
equationCriteriaanyNoA column name, list of column names, or comparer function used to determine which columns to check for duplicates. If omitted, all columns are compared.

Return Value

table — A table with duplicate rows removed.

Remarks

Table.Distinct removes duplicate rows from a table. Without equationCriteria, rows must match on every column to be considered duplicates. Pass a column name or list of column names to deduplicate based on specific columns only — the first occurrence of each unique value is kept.

Table.Distinct is the function the Remove Duplicates command in the Power Query editor writes; M has no separate Table.RemoveDuplicates function. Besides column names, equationCriteria can include a comparer such as Comparer.OrdinalIgnoreCase, so values that differ only in case count as duplicates.

Examples

Example 1: Get distinct categories

Table.Distinct(Table.SelectColumns(Sales, {"Category"}))
Output
Category
1Widgets
2Gadgets
3Misc

Example 2: Distinct customers by name

Table.SelectColumns(Table.Distinct(Sales, "CustomerName"), {"CustomerName", "Product", "Region"})
Output
CustomerName
Product
Region
1AliceWidget AEast
2BobGadget BWest
3CharlieWidget CEast
4DianaWidget AWest

Compatibility

✓ Power BI Desktop✓ Power BI Service✓ Excel Desktop✓ Excel Online✓ Dataflows✓ Fabric Notebooks
Contributors
kyleamueller