Sub topic 10
Grouping dates and numeric ranges
This chapter assumes you can insert a PivotTable and place fields in the Rows and Values areas. Grouping lets you roll many detailed values into fewer buckets, such as months, quarters, or price bands.
Why group
A Date field with hundreds of distinct days produces hundreds of rows. Grouping collapses them into months or quarters so the PivotTable answers a question like "How did sales change by month?"
The examples use this source data:
Date,Region,Product,Units,Sales
2025-01-05,East,Widget,10,250
2025-01-12,West,Gadget,4,180
2025-02-03,East,Gadget,7,315
2025-02-14,West,Widget,12,300
2025-03-09,East,Widget,5,125Grouping dates
- Put Date in Rows and Sales in Values.
- Right-click any date in the PivotTable and choose Group.
- In the Grouping dialog, select one or more units, such as Months and Years.
- Select OK.
Excel replaces the daily rows with the selected units. If you select Months only, January of different years merges into one row. Select Years as well to keep them apart.
In recent Excel versions, dragging a Date field into the PivotTable may group it automatically into Months. If you don't want that, right-click a date and choose Ungroup.
For custom spans, select Days and set Number of days, for example 7 for weekly totals. Only Days allows this, so deselect the other units.
Grouping numbers
Numeric fields can be grouped into equal-width bands. Put Units in Rows, right-click a value, and choose Group. Enter these values:
- Starting at: 0
- Ending at: 15
- By: 5
The rows become 0-4, 5-9, and 10-14. Add Sales to Values to see the total for each band. Note that the end value 15 is not shown as its own band here, so make Ending at large enough to include your highest number.
Grouping text items manually
You can also group non-numeric items. Select several items in Rows, such as East and West, right-click, and choose Group. Excel creates a group named Group1. Edit that cell to rename it. This is useful for combining regions into larger territories.
Common errors
| Symptom | Cause | Fix |
|---|---|---|
| "Cannot group that selection" | The date column has blanks or text values | Correct the source data, then refresh |
| Dates are not grouped by month | Dates are stored as text | Convert them to real dates |
| Months from different years are merged | Only Months was selected | Also select Years |
| New group does not appear after changes | The PivotTable is stale | Refresh it |
Exercise
Exercise
You group a Date field by Months only. The data covers January 2025 and January 2026. How many January rows appear, and how do you separate them?
Show answer
One January row appears, combining both years. Open the Group dialog again and select Years together with Months. The PivotTable then shows January separately under each year.
Exercise
You want to total Sales for each 5-unit band of Units. Which fields go where, and which Group settings do you use?
Show answer
Put Units in Rows and Sales in Values. Right-click a Units value, choose Group, and set Starting at 0, Ending at a number at or above the largest Units value, and By 5.