Table.RemoveDuplicates
TableRemoves duplicate rows from a table based on one or more key columns.
Syntax
Table.RemoveDuplicates(table as table, optional columns as any, optional equationCriteria as any) as tableParameters
| Name | Type | Required | Description |
|---|---|---|---|
table | table | Yes | The input table to deduplicate. |
columns | any | No | A column name or list of column names to check for duplicates. If omitted, all columns are compared. |
equationCriteria | any | No | Optional comparer function for custom equality logic. |
Return Value
table — A table with duplicate rows removed, keeping the first occurrence of each unique key.
Remarks
Table.RemoveDuplicates keeps the first occurrence of each unique combination of key column values and removes subsequent duplicates. When no columns are specified, the entire row is compared.
If you need to control which duplicate row is kept (e.g., keep the most recent or the lowest price), sort the table first with Table.Sort and then wrap the result in Table.Buffer before calling Table.RemoveDuplicates. Without Table.Buffer, the sort order is not guaranteed to be preserved, which means you may not keep the intended row.
Examples
Example 1: Remove duplicate customers
Table.RemoveDuplicates(Sales, {"CustomerName"})Result
OrderID | CustomerName | Product | Category | UnitPrice | Quantity | OrderDate | Region | |
|---|---|---|---|---|---|---|---|---|
| 1 | 1 | Alice | Widget A | Widgets | 25 | 4 | 1/15/2024 | East |
| 2 | 2 | Bob | Gadget B | Gadgets | 50 | 2 | 1/18/2024 | West |
| 3 | 3 | Charlie | Widget C | Widgets | 15 | 10 | 2/1/2024 | East |
| 4 | 5 | Diana | Widget A | Widgets | 25 | 6 | 3/5/2024 | West |
Example 2: Remove duplicates by multiple columns
Table.SelectColumns(
Table.RemoveDuplicates(Sales, {"Category", "Region"}),
{"CustomerName", "Category", "Region"}
)Result
CustomerName | Category | Region | |
|---|---|---|---|
| 1 | Alice | Widgets | East |
| 2 | Bob | Gadgets | West |
| 3 | Alice | Gadgets | North |
| 4 | Diana | Widgets | West |
| 5 | Bob | Misc | East |
| 6 | Diana | Widgets | North |
Compatibility
✓ Power BI Desktop✓ Power BI Service✓ Excel Desktop✓ Excel Online✓ Dataflows✓ Fabric Notebooks