Sub topic 12
What Happens to Groups When Data Changes
This chapter assumes you can build a PivotTable, group a date or number field with the Grouping dialog, and use helper columns in the source data. It explains what a refresh keeps, what it changes, and what it never does for you.
Groups belong to the PivotTable, not the data
A group is a setting stored in the PivotTable's cache, the hidden copy of the source data that the PivotTable reads. The source cells do not change when you group. Excel records the grouping rule, such as "Months and Years" or "Starting at 0, Ending at 100, By 10", and applies it to whatever values are in the cache.
So the rule survives a refresh. What the rule produces can change.
Refreshing after the values change
Right-click the PivotTable and choose Refresh, or press Alt+F5. Excel reloads the cache and applies the saved rules again.
| Change in the source | Result after refresh |
|---|---|
| A value is edited inside the existing range | The row moves to the group that now matches. Totals update. |
| New rows have dates or numbers inside the grouped range | The rows are counted in the matching groups. |
| New dates fall after the last grouped period | A new group appears if the unit is Months, Quarters, or Years and the Ending at value is set automatically. |
| New numbers fall beyond a fixed Ending at value | The numbers appear in a catch-all item such as ">100". |
| A date cell is replaced with text | The grouped field can no longer be grouped, and the grouping may be lost. |
The last row is the common failure. One text entry in a date column can cause Excel to drop the grouping on the next refresh. Fix the cell, refresh, and group again.
Fixed versus automatic limits
In the Grouping dialog, Starting at and Ending at are filled in from the data when you open it. If you leave them as they are, Excel stores them as fixed values. Two things follow from that:
- Data added later that falls outside those limits is not placed in a normal group.
- For a weekly grouping, the start date you chose is fixed. Every seven-day period is counted from that date.
If you expect the data to grow, reopen the dialog and set Ending at to a value beyond the data you expect. For dates, you can enter a far-future date.
New items and the Rows area
Grouped text items behave differently. When you manually group text items, Excel stores the names you selected. A new item that appears in the source, such as a new region, is not part of any group you made. It shows as its own entry in the field, outside the groups, until you add it by hand.
You can see this in the data flow below.
Helper columns are recalculated
If you grouped with a helper column, such as the fiscal year formula =YEAR(A2)+(MONTH(A2)>=7), the PivotTable does not recalculate it. The worksheet does. Two checks keep it working:
- Make sure the source is an Excel Table, so the formula fills down into new rows.
- Make sure the PivotTable's source is the Table, so the range grows with the data.
If the source is a fixed range like A1:D500, rows added at row 501 are not part of the PivotTable, however you group it. Change the source under PivotTable Analyze, Change Data Source, or rebuild the PivotTable from a Table.
Refresh settings that affect groups
- Right-click the PivotTable, choose PivotTable Options, then the Data tab. Turn on "Refresh data when opening the file" if the report must be current each time.
- On the Layout & Format tab, "Autofit column widths on update" can undo manual widths, but it does not touch groups.
- Copying a PivotTable's cache by building a second PivotTable from the first can share groups between the two. Changing the grouping in one then changes the other. To avoid this, create the second PivotTable from the original source.
Exercise
A PivotTable groups Order Amount into ranges of 10 from 0 to 100, and it is built from the fixed range A1:C500. You add 20 rows at row 501 and one of the new orders is 140. After refreshing, the new rows do not appear at all. What are two separate problems, and how do you fix each?
Show answer
First, the source range ends at row 500, so the new rows are not in the PivotTable. Fix this by changing the data source to an Excel Table or to a larger range. Second, the grouping has a fixed Ending at value of 100, so the 140 order would go to a catch-all item such as ">100" rather than a normal range. Fix this by reopening the Grouping dialog and raising Ending at, for example to 200.
Exercise
You group a date field by Months and Years. Next month the source gets rows dated in a new year, and one row's date was typed as text. What do you expect after refreshing?
Show answer
The valid dates in the new year appear in a new Year group, because Months and Years follow the calendar. The text entry cannot be treated as a date, so grouping can fail or be removed. Find the text cell with =ISNUMBER(A2), convert it to a real date, refresh, and regroup if needed.