Sub topic 1
What Grouping Does and Where to Find It
Prerequisites
This chapter assumes you can do the following:
- Move around Excel and enter basic formulas.
- Keep source data in a table or a contiguous range with one header row.
- Create a PivotTable and place fields in the Rows, Columns, and Values areas.
- Summarize a value field with Sum or Count.
The steps use the Windows desktop version of Excel for Microsoft 365. Menu names on Mac and in older versions differ slightly, and this chapter notes where that matters.
What grouping does
A PivotTable normally lists one row for every distinct value in a field. That works for a field such as Region, which has four or five values. It works badly for a field such as Order Date, which can have hundreds of distinct values. It also works badly for a numeric field such as Age or Price, where nearly every value is different.
Grouping combines several items of a field into one larger item. The PivotTable then summarizes each combined item as a single row or column. For example:
- Order dates from January 3, January 17, and January 29 become one item named "Jan".
- Ages 20, 23, and 27 become one item named "20-29".
- Text items such as "Apples" and "Pears" become one item named "Fruit".
Grouping happens inside the PivotTable. It does not change your source data, and it does not add a column to your worksheet. It changes how the PivotTable reads the field. This distinction matters later, when you decide between the Grouping dialog and a helper column in the source data.
The three kinds of grouping
Excel offers three kinds of grouping. Which one you get depends on the data type of the items you select.
| Field type | What you group by | Typical result |
|---|---|---|
| Date | Seconds, Minutes, Hours, Days, Months, Quarters, Years | Monthly or quarterly sales |
| Number | A start value, an end value, and a step size | Age bands, price ranges |
| Text | Items you pick by hand | Custom categories such as "Fruit" |
Date and number grouping are rule-based. You describe the rule, and Excel builds every group. Text grouping is manual. You select the items and Excel combines only those.
A before and after example
Suppose the source range has this layout, with one row per order:
| Order Date | Region | Amount |
|---|---|---|
| 2025-01-03 | East | 120 |
| 2025-01-17 | West | 80 |
| 2025-02-05 | East | 200 |
| 2025-04-11 | East | 150 |
| 2025-04-29 | West | 90 |
With Order Date in Rows and Amount in Values, the PivotTable shows five rows, one per date. After grouping by Months, it shows three rows.
| Row Labels | Sum of Amount |
|---|---|
| Jan | 200 |
| Feb | 200 |
| Apr | 240 |
| Grand Total | 640 |
Notice that March does not appear, because no order falls in March. When you group by a single unit such as Months, Excel lists only the months that have data. Chapter content on selecting several units, such as Years and Months together, comes later in this tutorial.
Where to find grouping
There are three entry points. All of them open or apply the same feature.
Right-click menu
- Click a cell in the field you want to group, for example one of the dates in the Row Labels column.
- Right-click the cell.
- Choose Group....
The Grouping dialog opens. For a date field, it lists the time units. For a number field, it shows Starting at, Ending at, and By boxes.
PivotTable Analyze tab
- Click a cell in the field.
- Open the PivotTable Analyze tab on the ribbon. In older versions this tab is named Analyze, and in Excel 2010 and earlier it is named Options.
- In the Group section, choose Group Selection or Group Field.
The two commands differ in what they act on:
- Group Field applies grouping to the whole field. Use it for dates and numbers.
- Group Selection applies grouping to the items you have selected. Use it for text, where you select the items first.
If the cell you clicked is not a groupable field, the commands are grayed out or an error appears. The chapter on diagnosing "Cannot group that selection" covers the causes.
Keyboard shortcut
Select the cells, then press Alt+Shift+Right Arrow to group and Alt+Shift+Left Arrow to ungroup. On a date or number field, the shortcut opens the Grouping dialog. On selected text items, it groups them immediately and creates a group named "Group1".
The Grouping dialog
For a date field, the dialog looks like this in outline:
- Starting at and Ending at: the first and last dates to include. Excel fills these from the data. Dates outside this range are collected into extra items labeled with "<" and ">" signs.
- By: a list of units. Click a unit to select it, and click it again to clear it.
- Number of days: available only when Days is the single selected unit. It controls the length of each period.
For a number field, the dialog has Starting at, Ending at, and By, where By is the width of each range. A later chapter walks through each box.
Keep the following in mind about the dialog:
- It applies to one field at a time.
- The OK button is unavailable when the selection cannot be grouped.
- Changes take effect for the whole field, not only for the cell you clicked.
How grouping appears in the field list
After you group a date field in Excel 2016 or later, new fields can appear in the PivotTable Fields pane. For example, grouping by Years and Months adds fields named Years and Months next to Order Date. These are not columns in your source data. They are part of the PivotTable's internal data cache, which is the stored copy of the source data that the PivotTable reads from.
You can drag the new fields between areas just like any other field. If you group by Months only, no separate field appears, and the original Order Date field itself shows months.
Choosing between the dialog and helper columns
The Grouping dialog handles most everyday needs, but it has limits. It cannot group by fiscal years, and it cannot build unequal number ranges such as 0 to 9, 10 to 49, and 50 and above. For those cases you add a formula column to the source data and use it as a field. Later chapters show the formulas.
The diagram shows how to decide which approach to use.
Requirements for grouping to work
Excel groups a field only when every item in it fits one data type. Before you try, check these points:
- Every cell in the date or number column holds a real date or number. A date typed as text, such as "Jan 3rd", is not a date.
- No cell in the column is blank. A blank cell in a date or number column blocks grouping in many versions of Excel.
- The column has a header, because the header becomes the field name.
A quick way to test a column is to add a temporary formula next to the source data:
=ISNUMBER(A2)The formula returns TRUE when the cell holds a real date or number, and FALSE when it holds text. Fill it down the column and look for any FALSE. Dates are stored as serial numbers, which is why they can be grouped like numbers. The next chapter explains that idea in detail.
Common mistakes at this stage
- Trying to group a row that is a subtotal or Grand Total. Click an item in the field, not a total.
- Expecting the source data to change. Grouping never edits your source range. If you need the groups in the source, use a helper column.
- Selecting several unrelated cells. For text grouping, select only the items you want in one group. Hold Ctrl to pick items that are not next to each other.
- Forgetting that the dialog affects the whole field. Grouping a date field by Months changes every place the field appears in that PivotTable.
Summary of what you can now do
You can say what grouping does, name the three kinds, and find the Group command in three places. You also know that grouping lives in the PivotTable and not in the source data, and you have a rule for when a helper column is the better choice.
Exercise
A PivotTable lists every order date on its own row. You group the Order Date field by Months only. The source data has orders in January, February, and April but none in March. How many month rows appear, and does the source data change?
Show answer
Three month rows appear (Jan, Feb, Apr), plus the Grand Total row. March is missing because no data falls in it. The source data does not change, because grouping happens only inside the PivotTable and its cache.
Exercise
You select three text items in the Row Labels column and want to combine them into one group. Which ribbon command and which keyboard shortcut do you use?
Show answer
On the PivotTable Analyze tab, choose Group Selection in the Group section. The keyboard shortcut is Alt+Shift+Right Arrow. Ungroup with Alt+Shift+Left Arrow.
Exercise
A colleague wants the PivotTable to group orders by a fiscal year that starts in July. Can the Grouping dialog do this? What should they do instead?
Show answer
No. The dialog groups only by calendar units, so Years always starts in January. They should add a helper column to the source data that calculates the fiscal year with a formula, then use that column as a field in the PivotTable.