A long sales list becomes useful when it is grouped by category with a total per group, and doing it by hand means a SUMIF per category that breaks when a category is added. Power Query Group By builds the totals table in one step, and it refreshes when the source data changes.
Prerequisites
- Excel with Power Query
- A table with a category column and a value column
- A copy of the source file, so the original stays untouched.
Steps
- Select the table and go to Data, From Table/Range to open it in the Power Query Editor.
- Go to Home, Group By, and choose the category column to group by.
- Add an aggregation, such as Sum, on the value column, and name the new column Total.
- Check the grouped totals against hand sums for two categories.
- Click Close and Load, then add the group totals together and compare with the grand total of the source.
Worked example: Fictional sales grouped by category
The practice table below is a fictional grouped totals list: three categories. The amount column is the category total, and the total is their sum. The table below is fictional practice material, with fictional values. It is the expected result, worked out by hand, not a run of any tool.
| Category | Total |
|---|---|
| Books | 215.00 |
| Stationery | 98.50 |
| Toys | 142.75 |
| Total | 456.25 |
Expected result. Three categories grouped, each total matches the hand sum, and the totals add to 456.25.
Limits
- Group By needs clean category values, so fix spelling variants before grouping.
- A group total hides the rows behind it, so keep the source table for checking.
