Table.Distinct Function in Power Query
The Table.Distinct function removes duplicate rows from a table, ensuring that all remaining rows are distinct. An optional parameter, equationCriteria, specifies which columns of the table are tested for duplication. If equationCriteria is not specified, all columns are tested.
Syntax
Table.Distinct(table as table, optional equationCriteria as any) as table
Note: The Table.Distinct function checks for duplicates with case sensitivity.
Example: Remove the duplicates from the table.
Power Query M
let MyTable = Table.FromRecords( { [CustomerID = 1, Name = "Ashish", Phone = "123-4567", Company = "TCS"], [CustomerID = 1, Name = "Ashish", Phone = "123-4567", Company = "TCS"], [CustomerID = 2, Name = "Katrina", Phone = "987-6543", Company = "TCS"], [CustomerID = 3, Name = "Alia", Phone = "543-7890", Company = "TCS"], [CustomerID = 3, Name = "alia", Phone = "543-7890", Company = "TCS"], [CustomerID = 4, Name = "Vicky", Phone = "676-8479", Company = "TCS"], [CustomerID = 4, Name = "Vicky", Phone = "676-8479", Company = "TCS"], [CustomerID = 5, Name = "Mohini", Phone = "574-8864", Company = "TCS"], [CustomerID = 6, Name = "Meenakshi", Phone = "574-8864", Company = "TCS"], [CustomerID = 7, Name = "Esha", Phone = "574-8864", Company = "TCS"], [CustomerID = 7, Name = "Esha", Phone = "574-8864", Company = "TCS"], [CustomerID = 8, Name = "Anjali", Phone = "574-8864", Company = "TCS"], [CustomerID = 6, Name = "Meenakshi", Phone = "574-8864", Company = "TCS"] } ), Return = Table.Distinct(MyTable) in Return
The output of the above code is shown below: