Sub topic 4
Selecting Several Units at Once
This chapter assumes you can build a PivotTable with a date field in Rows, that your source dates are real dates (not text), and that you have already opened the Grouping dialog for a date field. Here you will combine several units in one grouping and learn how the order and layout affect the result.
What multi-unit grouping does
In the Grouping dialog, the By list lets you select more than one unit. Click a unit to highlight it, and click it again to clear it. Each selected unit becomes its own level in the PivotTable.
If you select Years, Quarters, and Months, Excel creates three fields from the one date field. The fields always appear from the largest unit to the smallest, whatever order you clicked them in.
| Selected units | Fields created |
|---|---|
| Months | Months |
| Years, Months | Years, Months (date) |
| Years, Quarters, Months | Years, Quarters, Date |
The last row shows a detail to remember. The original field keeps the name of your date field and holds the smallest unit you chose. Excel adds a new field for each larger unit.
Worked example
Suppose a table named Orders has the columns OrderDate, Region, and Amount. You build a PivotTable with OrderDate in Rows and Sum of Amount in Values.
- Right-click any date in the Rows area.
- Choose Group.
- In the By list, select Months, Quarters, and Years. Leave Starting at and Ending at as they are.
- Click OK.
The Rows area now shows Years, Quarters, and OrderDate. If you chose Months as the smallest unit, the last field is named OrderDate and its items read Jan, Feb, and so on.
Why the field list changes
Grouping adds fields to the PivotTable field list. You can drag each new field on its own. For example, you can put Years in Columns and Months in Rows to compare years side by side.
The new fields exist only in the PivotTable. They are not added as columns in your source data. This matters when you build a second PivotTable from the same source. It starts with the ungrouped date field unless it shares the same PivotCache (the stored copy of the source data).
Common errors and how to avoid them
- Months merge across years. This happens when Years is not selected. Reopen the dialog and add Years.
- Days appear with other units. Selecting Days together with Months or Years is allowed, but the Days unit only works as the single smallest unit. If you also need weekly periods, you must group Days alone, which is covered in a later chapter.
- Missing months. A month with no orders does not appear unless you turn on Show items with no data in Field Settings, on the Layout & Print tab.
- Quarters are calendar quarters. Excel Q1 is always January to March. A July fiscal year needs a helper column, which a later chapter covers.
- The dialog refuses to open. The "Cannot group that selection" error means the field has text, blanks, or errors. A later chapter covers how to fix it.
Changing the layout after grouping
Once grouped, you can collapse and expand each level with the plus and minus buttons beside an item. To show all levels as separate columns instead of an indented list, go to Design, then Report Layout, then Show in Tabular Form. Tabular form makes it easier to copy the result and to read Years, Quarters, and Months as distinct columns.
To show a year total above its quarters, keep the default subtotals on. To hide them, use Design, then Subtotals, then Do Not Show Subtotals.
Check your understanding
Exercise
A PivotTable has a grouped date field with only Months selected. The source data covers 2023 and 2024. The Jan row shows a total that looks too high. What caused it, and how do you fix it?
Show answer
Without Years selected, Excel combines January 2023 and January 2024 into one "Jan" row. Right-click a date item, choose Group, and select Years as well as Months. Click OK. The table then separates each month by year.
Exercise
You group a date field by Years, Quarters, and Months. Which of the three new fields keeps the original field name, and which unit does it show?
Show answer
The original field name (for example OrderDate) stays on the smallest unit you selected, which is Months. Excel adds new fields named Years and Quarters for the larger units.