Sub topic 3
Ungrouping and Changing a Grouping
Assume you can create a PivotTable and place fields in Rows, Columns, and Values. Grouping changes how PivotTable items are displayed; it does not change the source values.
Ungrouping and changing a grouping
To remove a grouping, select any grouped item in the PivotTable. Choose PivotTable Analyze > Ungroup, or right-click the item and choose Ungroup.
To change a grouping, select a grouped item and choose PivotTable Analyze > Group Field. Adjust the settings, such as Starting at, Ending at, and By. For dates, choose units such as Months, Quarters, or Years. For numbers, set the interval.
The grouping applies to the PivotTable field. It may create fields such as Years, Quarters, or Months alongside the original field.
=ISNUMBER(A2)Use this test when a date grouping fails. TRUE means Excel recognizes the value as a number or date. FALSE often means the cell contains text.
Fixing “Cannot group that selection”
Excel commonly shows this error when a date or number field contains one or more of the following:
- Blank cells or formulas that return an empty string
- Text dates mixed with real dates
- Error values
- Different data types in the same field
- A selected item that is not part of the intended field
Inspect the entire source column, not only the visible PivotTable items. Convert text dates to real dates, remove errors, and fill or exclude blanks. Then refresh the PivotTable and try grouping again.
Helper columns for fiscal years and custom buckets
Use a helper column when the Grouping dialog cannot express your business rule. A helper column is a calculated source-data column used as a PivotTable field.
For a fiscal year starting in July, with the year named for the year in which it ends, enter:
=YEAR(A2)+(MONTH(A2)>=7)For fiscal quarters:
="Q"&(INT(MOD(MONTH(A2)-7,12)/3)+1)For numeric buckets of 10:
=FLOOR(B2,10)Refresh the PivotTable after adding these columns, then use the helper fields in Rows or Columns.
What happens when data changes
Grouping settings usually remain when you refresh existing records. New dates or numbers may appear as items within the existing groups. However, a refresh does not automatically repair invalid source values or necessarily extend a fixed source range.
Use an Excel Table as the PivotTable source so added rows are included more reliably. Refresh after changing data. If the grouping still behaves incorrectly, inspect the source field and verify the grouping boundaries.
Exercise
A date field contains one text date and several blank cells. What should you do before grouping it by month?
Show answer
Convert the text date to a real date, remove or handle the blanks, refresh the PivotTable, and try grouping again.