Sub topic 6
Grouping Numbers into Equal-Width Ranges
This chapter assumes you can build a PivotTable, place fields in Rows and Values, and use Sum and Count. You also need source data in a table or contiguous range with one header row.
What number grouping does
A PivotTable lists every distinct value in a numeric field as its own row. With ages, prices, or scores, that gives you hundreds of rows. Grouping replaces them with ranges of equal width, such as 0-9, 10-19, and 20-29. Each range becomes one row, and the Values area summarizes all the records that fall inside it.
Excel can do this because numbers have an order and a size. It only needs a start, an end, and a step.
Group a numeric field
The example uses a source table with the columns Customer, Age, and Spend. You want to know how many customers fall into each ten-year age band and how much each band spent.
- Build a PivotTable. Put
Agein Rows. PutCustomerin Values, summarized by Count. PutSpendin Values, summarized by Sum. - Right-click any age value in the Rows area and choose Group. You can also select the cell and use PivotTable Analyze > Group Selection.
- In the Grouping dialog, fill in three boxes:
- Starting at: the lowest value to include.
- Ending at: the highest value to include.
- By: the width of each range.
- Enter
20,69, and10, then select OK.
Excel proposes the smallest and largest values in the field as the defaults for Starting at and Ending at. Change them if you want cleaner boundaries.
The labels look like 20-29, 30-39, and so on. Each range includes its start value and runs up to, but does not include, the next start. A customer aged exactly 30 lands in 30-39.
What happens at the edges
Values outside the Starting at and Ending at limits are not dropped. Excel collects them into two extra rows labeled <20 and >69 in this example. This lets you ignore outliers in the main bands while keeping the totals correct.
If you leave the defaults, no edge rows appear, because every value is already inside the limits.
Choosing a good width
- Pick a width that matches how people talk about the data, such as 10 years, 100 dollars, or 5 points.
- Start the first range at a round number. If the youngest customer is 18, starting at 18 gives odd labels like
18-27. Starting at 10 or 20 reads better. - Try a width, look at the result, and change it. You can reopen the dialog at any time.
Doing the same thing with a helper column
The Grouping dialog works on the PivotTable only. If you need the bucket as a real column in the source data, for filtering, formulas, or other reports, calculate it yourself. This formula rounds a positive number down to the nearest multiple of 10:
=FLOOR(B2,10)If B2 holds 37, the result is 30. This gives the same buckets as grouping by 10 in the PivotTable. Fill the formula down, add the new column to the PivotTable source, and use it in Rows. The labels will show only the lower bound (30), so you need to rename or label them yourself if you want 30-39.
Common problems
| Symptom | Likely cause | Fix |
|---|---|---|
| "Cannot group that selection" | The field has text, blanks, or errors mixed in with the numbers | Clean the source column, then refresh |
| Ranges are not the width you expected | You accepted default Starting at or By values | Reopen the dialog and set the values |
| Extra `<` and `>` rows appear | Some values fall outside the limits | Widen the limits or keep the rows on purpose |
| Group option is grayed out | Several non-adjacent items are selected | Select a single cell in the field |
A later chapter covers the "Cannot group that selection" error in detail.
Exercise
A PivotTable shows the field Score with values from 3 to 98. You group it with Starting at = 10, Ending at = 90, and By = 20. Which rows appear, and in which row does a score of 90 fall?
Show answer
The rows are <10, 10-29, 30-49, 50-69, 70-90, and >90. Scores of 3 to 9 go into <10, and scores above 90 go into >90. A score of 90 equals the Ending at value, so it is inside the last range, 70-90.
Exercise
You need a column in the source data that places each value in B2 into a bucket of width 10 (0, 10, 20, and so on). Which formula do you use, and what does it return for 37?
Show answer
Use =FLOOR(B2,10). For 37 it returns 30.