Table.Group Function in Power Query
The Table.Group function groups table rows by the values of key columns for each row.
Syntax
Table.Group(table as table, key as any, aggregatedColumns as list) as table
Example:
Power Query M
let MyTable = Table.FromRecords( { [CustomerID = 1, Name = "Ashish", Score = 12, Company = "TCS"], [CustomerID = 2, Name = "Katrina", Score = 20, Company = "TCS"], [CustomerID = 1, Name = "Ashish", Score = 50, Company = "TCS"], [CustomerID = 3, Name = "Anjali", Score = 60, Company = "TCS"], [CustomerID = 4, Name = "Esha", Score = 55, Company = "TCS"], [CustomerID = 5, Name = "Meenakshi", Score = 40, Company = "TCS"], [CustomerID = 4, Name = "Esha", Score = 30, Company = "TCS"], [CustomerID = 3, Name = "Anjali", Score = 25, Company = "TCS"] } ), Return = Table.Group(MyTable, "CustomerID", {"Total Score", each List.Sum([Score])}) in Return
The output of the above code is shown below: