Sub topic 5
Grouping data with rows and columns
This chapter covers how the Rows and Columns sections of the pivot table editor control the shape of a summary. It assumes you can already create a pivot table from a prepared range and open the editor. You should also know that a Values field aggregates numbers. Summarize by options are covered in the next chapter, so the examples here use the default Sum.
The working model
A pivot table reads every record in the source range and sorts each one into a cell. The Rows and Columns sections decide which cell a record lands in.
- Each field you add to Rows contributes one category per unique value. The table gets one row per category.
- Each field you add to Columns does the same, but the categories run across the top.
- Values is then calculated once per cell, using only the records that match both the row category and the column category.
The examples use a Sales sheet with a header row and these columns:
| Order ID | Region | Rep | Product | Date | Revenue |
|---|---|---|---|---|---|
| 1001 | West | Ana | Widget | 2026-01-14 | 1200 |
| 1002 | East | Ben | Gadget | 2026-01-20 | 800 |
| 1003 | West | Ana | Gadget | 2026-02-03 | 450 |
| 1004 | East | Cleo | Widget | 2026-02-11 | 950 |
| 1005 | West | Dev | Widget | 2026-02-19 | 300 |
One field in Rows
Start with the simplest layout.
- Select the data range and choose Insert > Pivot table.
- In the editor, next to Rows, click Add and choose Region.
- Next to Values, click Add and choose Revenue.
The result has one row per region, with the summed revenue beside it:
| Region | SUM of Revenue |
|---|---|
| East | 1750 |
| West | 1950 |
| Grand Total | 3700 |
This is the same summary that =SUMIFS(Sales!F:F, Sales!B:B, "West") gives for one region. The pivot table produces every region at once and picks up new regions as they appear in the data.
Adding a second field to Rows
Adding another field to Rows nests it inside the first one. Add Rep below Region.
| Region | Rep | SUM of Revenue |
|---|---|---|
| East | Ben | 800 |
| East | Cleo | 950 |
| West | Ana | 1650 |
| West | Dev | 300 |
Two points matter here.
- Order is meaning. Region above Rep gives "reps within each region". Reverse the order and the table reads "regions within each rep". The numbers do not change, but the question the table answers does. Drag the fields in the editor to reorder them.
- Nesting multiplies rows. The row count is the number of unique combinations that actually occur, not the product of the two category counts. Combinations with no records, such as East with Ana, do not appear. Adding a high-cardinality field such as Order ID produces one row per record, which defeats the purpose of summarizing.
Using Columns
Move a field to Columns when you want to compare categories side by side. Keep Region in Rows and add Product to Columns.
| Region | Gadget | Widget | Grand Total |
|---|---|---|---|
| East | 800 | 950 | 1750 |
| West | 450 | 1500 | 1950 |
| Grand Total | 1250 | 2450 | 3700 |
The West and Widget cell is 1500 because orders 1001 and 1005 both match (1200 + 300). A cell is empty when no record matches that pair.
Choosing between Rows and Columns
Both sections group the same way. The choice is about readability.
- Put the field with many categories in Rows. A table can grow downward easily, but wide tables force horizontal scrolling.
- Put the field with few categories (for example, 2 to 6) in Columns so the comparison fits on screen.
- If you plan to chart the result, the Columns field usually becomes the series (the colors or lines) and the Rows field becomes the axis.
Each field has its own options
Click a field's name in the editor to open its options. For fields in Rows and Columns you will see the following.
| Option | What it does |
|---|---|
| Order | Ascending or descending. |
| Sort by | Sorts by the field's own labels or by a Values field. |
| Show totals | Turns the subtotal for that field on or off. |
| Repeat row labels | Repeats the outer label on every row. This helps if you copy the table elsewhere. |
| Show blank values | Controls whether empty source cells appear as a category. |
Sorting and totals are covered in a later chapter. The options you most need for grouping are Show totals and Repeat row labels.
Subtotals with nested fields
With two fields in Rows, the pivot table adds a subtotal row for each outer category, and the layout changes:
| Region | Rep | SUM of Revenue |
|---|---|---|
| East | 1750 | |
| Ben | 800 | |
| Cleo | 950 | |
| West | 1950 | |
| Ana | 1650 | |
| Dev | 300 |
The outer label appears only once, and the subtotal sits on its own row. If you plan to reference these cells with formulas, or copy them into another sheet, turn on Repeat row labels and turn off Show totals for the outer field. This gives a flat table in which every row is complete.
Blanks and inconsistent labels
Grouping depends on exact matches between values, so data quality problems show up directly in the layout.
- Blank cells in a grouping field form their own category. They appear as a row labeled with an empty string or as "(blank)" style output. To hide them, open the field options and clear Show blank values, or fix the source data.
- Spelling and spacing differences create separate categories. "West", "west" and "West " (with a trailing space) can show up as separate rows. Case is generally merged, but extra spaces and typos are not.
- Numbers stored as text group separately from real numbers. A value of
2026as text and2026as a number can appear as two rows.
A quick check is to scan the Rows list for categories that look like duplicates. If you find some, fix the source with TRIM or a find-and-replace, and the pivot table updates.
Grouping by the same field in both places
A field can be used only in one section at a time through the normal editor flow, but you can add the same source column to Rows and to Values. For example, put Product in Rows and also in Values with COUNTA. This gives a count of records per product next to its name. The grouping and the calculation are separate roles for the same column.
Reading the layout when something looks wrong
| Symptom | Likely cause |
|---|---|
| A category you expect is missing | The source range excludes those rows, or a filter hides them. |
| A category appears twice | The labels differ in spelling, spacing or data type. |
| A "blank" row appears | Some source cells in that field are empty. |
| The table is very long | A high-cardinality field, such as an ID, is in Rows. |
| Cells are empty in the grid | No record matches that row and column pair. This is normal. |
Check your understanding
Exercise
Using the Sales table above, you put Region in Rows, Product in Columns, and Revenue in Values with Sum. A colleague says the East and Gadget cell should show 1250. What value does the pivot table show, and which two orders are involved?
Show answer
The cell shows 800. Only order 1002 matches both East and Gadget. The figure 1250 is the Gadget column total across both regions (800 from East plus 450 from West, from orders 1002 and 1003).
Exercise
You want to copy a pivot table with Region and Rep in Rows into another sheet as a flat list where every row has its own Region label and there are no subtotal rows. Which two options do you change on the Region field?
Show answer
Turn on Repeat row labels, and turn off Show totals for the Region field.
Exercise
A pivot table of revenue by Region shows both "West" and "West " as separate rows. Why does this happen, and how do you fix it?
Show answer
The pivot table groups by exact values, and the second value has a trailing space, so it counts as a different category. Fix the source data, for example with TRIM or find-and-replace, and the two rows merge when the pivot table refreshes.