Grouping in Excel Power Query lets you collapse many rows into one summary row per category — for example, total sales per region or average order value per customer. The feature is built into the Power Query Editor: load your data, select the column(s) to group by, and use the Group By command on the Home or Transform tab. No add-ins are needed, and it works in Excel 2016 and later on Windows and Mac.
What You'll Need
- Excel 2016 or later (Power Query is built in; in older versions it was an add-in called Power Query).
- Data in a table or range, or an external source you can connect to.
- Basic familiarity with the Power Query Editor window (the separate editor that opens when you edit a query).
Step-by-Step
- Load your data into Power Query. Select a cell in your table, then go to Data > From Table/Range (or Data > Get Data for external sources). The Power Query Editor opens. Menu labels can differ slightly by Excel version and platform, but the Group By command is present in all current versions.
- Clean the columns first. Grouping works on the values as they are. Trim spaces, fix inconsistent capitalisation, and remove blank rows before grouping; otherwise “North” and “North ” will be treated as different groups. Use Transform > Format > Trim and Transform > Format > Capitalize Each Word if needed.
- Select the column(s) you want to group by. Click the column header. To group by more than one column, hold Ctrl (Windows) or Command (Mac) and click each additional header. The order of selection does not matter for the grouping itself, but the resulting table will show the grouped columns in the order you selected them.
- Open the Group By dialog. On the Home tab, click Group By (it also appears on the Transform tab). The dialog has three parts: the grouping columns, a New column name box, and an Operation dropdown with a Column dropdown.
- Set the grouping columns. The columns you selected appear in the top list. If you need to add or remove one, use the dropdown there rather than closing the dialog.
- Choose the operation and the column to aggregate. For each summary you want, enter a name in New column name (for example, “Total Sales”), pick an Operation such as Sum, Average, Count Rows, Min, or Max, and choose the Column to aggregate. Click Add aggregation to create more than one summary column in the same step.
- Click OK. Power Query adds a Grouped Rows step to the Applied Steps list and shows the collapsed table. Each row now represents one unique combination of your grouping columns.
- Check the result. Compare a couple of totals against the original data with a quick filter or by using the arrow filter on a grouped column. If a number looks wrong, the usual cause is text that looks numeric (for example, numbers stored as text) or extra spaces in the grouping column.
- Expand or adjust if needed. If you grouped by a column that contains a table (for example, after grouping by All Rows), use the expand icon in the column header to bring fields back out. To change the grouping, click the gear icon next to the Grouped Rows step in Applied Steps and edit the dialog.
- Load the result. Go to Home > Close & Load (or Close & Load To to choose a worksheet location or the Data Model). The grouped table appears in Excel as a new query output.
Common Mistakes
- Grouping before cleaning. Leading or trailing spaces, inconsistent case, and blank cells create extra groups. Clean first, then group.
- Forgetting to add an aggregation. If you click OK without adding at least one operation, Power Query may return only the distinct grouping values — useful, but not a summary.
- Choosing the wrong operation. Sum on a text column or Count on a numeric column gives unexpected results. Match the operation to the data type.
- Grouping by too many columns. Adding a column such as Order ID to the grouping list makes almost every row its own group, so the summary looks like the original data.
- Editing the output table in Excel. Changes made to the loaded table are overwritten on refresh. Make changes in the query, not the sheet.
Tips
- Use Count Rows to count records per group; use Count Distinct (available in the Operation list in current versions) to count unique values such as unique customers.
- Rename the grouped columns immediately so later steps and the loaded table are readable.
- If you need the detail rows as well as the summary, group by All Rows instead of a column, then expand the resulting table column.
- Keep the Applied Steps panel tidy: delete unnecessary steps and give key steps descriptive names via right-click > Rename.
- Grouping is a query step, so refreshing the query re-applies it to new data automatically — no need to rebuild the summary each time.
Troubleshooting
- The Group By button is greyed out. Make sure the query output is a table, not a single value or a chart. Click a column header first; the command needs a selected column.
- Totals do not match Excel SUM or AVERAGE. Check for numbers stored as text (the column header shows ABC instead of 123). Change the data type with Transform > Data Type, then re-check the step.
- Extra groups appear. Use Transform > Format > Trim and Clean, and check for blank rows. Filter out nulls in the grouping column before grouping.
- The step errors after a refresh. A column referenced by the Group By step may have been renamed or removed at the source. Open the gear icon on the Grouped Rows step and reselect the column.
- You cannot find the gear icon. It appears to the right of the step name in Applied Steps; if the panel is hidden, turn it on from the View tab.
- Grouping on a date column gives one group per day. That is expected. To group by month or year, add a calculated column first (Add Column > Date > Year or Month) and group by that.
Frequently Asked Questions
Can I group by more than one column?
Yes. Select multiple columns with Ctrl or Command before opening Group By, or add them in the dialog's grouping list.
Does grouping delete my original data?
No. Grouping is a step in the query; the source data is unchanged. You can delete the step or edit it at any time.
Can I group by month or year?
Not directly from a date column. Add a Year or Month column with Add Column > Date, then group by that new column.
Why does my grouped table show only unique values with no totals?
No aggregation was added in the Group By dialog. Edit the step and add at least one operation such as Sum or Count Rows.
Does Group By work in Excel on Mac?
Yes, Power Query including Group By is available in current Excel for Mac. Menu positions may differ slightly from Windows.
Can I undo a Group By step?
Yes. In Applied Steps, click the X next to the Grouped Rows step or right-click and delete it. The query returns to the previous step.