Group By in Excel: How to Summarize Data Quickly
In this article
Grouping in Excel allows you to consolidate multiple rows of data into a single summary row based on a shared category, such as grouping daily sales into monthly totals or individual employees into departments. This is primarily achieved using Pivot Tables or the Subtotal feature, which transforms a flat list of data into an organized hierarchy that is easier to analyze and report on.
What You'll Need
- A dataset with clear column headers (e.g., Date, Category, Amount).
- Consistent data entry (e.g., "North Region" should not be written as "North" in some rows and "North Region" in others).
- Excel installed on Windows or Mac (menu labels may vary slightly by version or region).
Step-by-Step
There are two primary ways to "group by" in Excel. The Pivot Table method is the modern standard for analysis, while the Subtotal method is better for quick, printable lists. Both are detailed below.
Method 1: Grouping via Pivot Tables (Recommended)
- Prepare your data: Ensure your data is in a continuous range with no completely empty rows or columns. Click any cell within your data range.
- Insert the Pivot Table: Go to the Insert tab on the top ribbon and click PivotTable. In the dialog box, ensure your data range is correct and select whether you want the table in a New Worksheet or the Existing Worksheet, then click OK.
- Set up the fields: You will see the PivotTable Fields pane on the right. Drag the column you want to group by (e.g., "Category" or "Date") into the Rows area. Drag the column you want to calculate (e.g., "Sales Amount") into the Values area.
- Group the data: If you are grouping by a date or number, right-click any value in the Row labels of the actual Pivot Table. Select Group... from the context menu.
- Choose the grouping interval: A dialog box will appear. For dates, you can select Seconds, Minutes, Hours, Days, Months, Quarters, or Years. You can select multiple options (e.g., Months and Years) to create a nested hierarchy. Click OK.
- Refine the calculation: By default, Excel sums numbers. If you need the average or count instead, right-click a value in the Values area, select Summarize Values By, and choose your preferred calculation.
Method 2: Grouping via the Subtotal Feature
- Sort your data: This is the most critical step for Subtotals. Select your data and go to the Data tab, then click Sort. Sort by the column you intend to group by (e.g., Sort by "Department" A to Z). If you skip this, Excel will create a new subtotal every time the value changes, resulting in a fragmented list.
- Apply Subtotals: With your data still selected, go to the Data tab and click the Subtotal button (usually found in the "Outline" group on the far right).
- Configure the Subtotal settings: In the pop-up window:
- At each change in: Select the column you sorted in Step 1.
- Use function: Choose Sum, Count, Average, Max, or Min.
- Add subtotal to: Check the box for the column containing the numbers you want to calculate.
- Finalize: Click OK. Excel will now insert rows containing the totals for each group.
- Use the Outline View: On the left side of the screen, you will see small numbers (1, 2, 3). Clicking "2" collapses the detail and shows only the group totals; clicking "3" expands everything.
Common Mistakes
One of the most frequent errors is attempting to use the Subtotal feature without sorting the data first. Because the Subtotal tool only looks for a "change in value" from one row to the next, unsorted data will lead to dozens of redundant subtotals for the same category, making the report useless.
Another common mistake is inconsistent naming. Excel treats "Apple" and "Apple " (with a trailing space) as two different categories. This results in your "Group By" operation creating two separate groups for what should be one. Always use the Find and Replace tool (Ctrl+H) to standardize your categories before grouping.
Users also often forget to refresh their Pivot Tables. Unlike standard formulas, Pivot Tables do not update automatically when you change the source data. If you add new rows to your list, you must right-click the Pivot Table and select Refresh to see the updated grouped totals.
Tips
To make your grouped data more professional, use the Design tab (which appears when you click inside a Pivot Table) to change the report layout. Switching to "Tabular Form" often makes the data look more like a traditional table and less like a collapsed list.
If you are dealing with very large datasets, convert your source data into an official Excel Table (Ctrl+T) before creating a Pivot Table. This ensures that as you add new rows to the bottom of your list, the Pivot Table automatically recognizes the expanded range upon refreshing, so you don't have to manually update the data source range.
For those using the Subtotal method, remember that you can nest subtotals. You can group by "Region" first, then apply a second subtotal grouped by "City." Excel will keep the first set of totals and add the second layer beneath them, provided you uncheck the "Replace current subtotals" box in the Subtotal dialog.
Troubleshooting
The "Group" option is greyed out in Pivot Tables: This usually happens because there is a data type mismatch in your column. To fix this, select the column, use Find and Replace to remove non-date text, or fill blanks with a placeholder date. After cleaning the data, refresh the Pivot Table and try grouping again.
Subtotals are not appearing correctly: Check if your data is formatted as an official Excel Table (the kind with banded rows and filter buttons in the header). The Subtotal feature is disabled inside official Tables. To use it, go to the Table Design tab and click Convert to Range. Once the data is back to a standard range, the Subtotal button will be active.
Calculations are showing "Count" instead of "Sum": This occurs when Excel detects non-numeric data in your value column. Check for numbers stored as text (often indicated by a small green triangle in the corner of the cell). Select the affected cells, click the warning icon, and choose Convert to Number.
Frequently Asked Questions
Can I group by multiple columns at once?
Yes. In a Pivot Table, simply drag multiple fields into the Rows area. The field at the top of the list becomes the primary group, and the field below it becomes a sub-group.
How do I ungroup data?
For Pivot Tables, right-click the grouped value and select Ungroup. For the Subtotal feature, go to the Data tab, click Subtotal, and select the Remove All button in the bottom left of the dialog box.
Is there a way to group by a custom list?
Yes. In a Pivot Table, you can select multiple items in a row (holding Ctrl), right-click, and select Group. Excel will create a new group (e.g., "Group 1") containing those specific items, which you can then rename.
Does grouping change my original data?
Pivot Tables create a separate summary, leaving your original data untouched. The Subtotal feature, however, inserts new rows directly into your dataset. It is recommended to make a backup copy of your sheet before using the Subtotal tool.
Can I group by a specific number of days (e.g., every 7 days)?
Yes. When grouping numbers or dates in a Pivot Table, the Group dialog allows you to set the "By" interval. For dates, you can choose days and then specify the number of days (e.g., 7) to create weekly groupings.