Table.RemoveDuplicates

Table

Removes duplicate rows from a table based on one or more key columns.

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

Syntax

Table.RemoveDuplicates(table as table, optional columns as any, optional equationCriteria as any) as table

Parameters

NameTypeRequiredDescription
tabletableYesThe input table to deduplicate.
columnsanyNoA column name or list of column names to check for duplicates. If omitted, all columns are compared.
equationCriteriaanyNoOptional comparer function for custom equality logic.

Return Value

tableA 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
11AliceWidget AWidgets2541/15/2024East
22BobGadget BGadgets5021/18/2024West
33CharlieWidget CWidgets15102/1/2024East
45DianaWidget AWidgets2563/5/2024West

Example 2: Remove duplicates by multiple columns

Table.SelectColumns(
    Table.RemoveDuplicates(Sales, {"Category", "Region"}),
    {"CustomerName", "Category", "Region"}
)
Result
CustomerName
Category
Region
1AliceWidgetsEast
2BobGadgetsWest
3AliceGadgetsNorth
4DianaWidgetsWest
5BobMiscEast
6DianaWidgetsNorth

Compatibility

Power BI Desktop Power BI Service Excel Desktop Excel Online Dataflows Fabric Notebooks