Excel Subtotal and grouping: outline levels 1-2-3 and +/− buttons
Add automatic totals for every city or department with Data → Subtotal, switch between outline levels 1-2-3, group rows, and copy a collapsed view correctly.
In a sales report, a manager usually wants a total for each city, not every single record. Inserting a row under each group by hand and typing SUM is slow and error-prone.
The Subtotal command does it in one go: it adds a total row under each group and a grand total at the end, and builds an outline on the left. The outline buttons let you hide the details and show only the totals.
| A | B | C | D | |
|---|---|---|---|---|
| 1 | City | Product | Amount | |
| 2 | Bukhara | Flour | 1 650 000 | |
| 3 | Bukhara | Bread | 480 000 | |
| 4 | Bukhara Total | 2 130 000 | ||
| 5 | Samarkand | Rice | 2 250 000 | |
| 6 | Samarkand | Oil | 540 000 | |
| 7 | Samarkand Total | 2 790 000 | ||
| 8 | Tashkent | Tea | 1 200 000 | |
| 9 | Tashkent | Sugar | 780 000 | |
| 10 | Tashkent Total | 1 980 000 | ||
| 11 | Grand Total | 6 900 000 | ||
| 12 |
Adding subtotals
1
First sort the table by the column you group by: click a cell in the City column → Данные → Сортировка от А до Я. This step is mandatory — the warning below explains why.
| A | B | C | D | |
|---|---|---|---|---|
| 1 | City | Product | Amount | |
| 2 | Bukhara1 | Flour | 1 650 000 | |
| 3 | Bukhara | Bread | 480 000 | |
| 4 | Samarkand | Rice | 2 250 000 | |
| 5 | Samarkand | Oil | 540 000 | |
| 6 | Tashkent | Tea | 1 200 000 | |
| 7 | Tashkent | Sugar | 780 000 | |
| 8 |
2
With a cell in the table selected, click Subtotal in the Outline group of the Данные tab. In the dialog: At each change in — City (a new group starts whenever this column changes), Use function — Sum, and in Add subtotal to — Amount.
| A | B | C | D | |
|---|---|---|---|---|
| 1 | City | Product | Amount | |
| 2 | Bukhara | Flour | 1 650 000 | |
| 3 | Bukhara | Bread | 480 000 | |
| 4 | Samarkand | Rice | 2 250 000 | |
| 5 | Samarkand | Oil | 540 000 | |
| 6 | Tashkent | Tea | 1 200 000 | |
| 7 | Tashkent | Sugar | 780 000 | |
| 8 |
3
Click OK. Excel adds a total row (with a =ПРОМЕЖУТОЧНЫЕ.ИТОГИ(9;…) formula) under each city and a grand total at the end. You can rename the “Bukhara Total” and “Grand Total” labels however you like.
Levels 1-2-3 and the +/− buttons
After Subtotal, an outline bar appears to the left of the row numbers:
- Button 1 at the top — the grand total only.
- 2 — city totals plus the grand total (the most useful view for a manager).
- 3 — all the details.
- The − button next to a group collapses it, + expands it.
Nothing is deleted — rows are only hidden. Formulas always calculate on the full data.
| A | B | C | D | |
|---|---|---|---|---|
| 1 | City | Product | Amount | |
| 2 | Bukhara Total | 2 130 000 | ||
| 3 | Samarkand Total | 2 790 000 | ||
| 4 | Tashkent Total | 1 980 000 | ||
| 5 | Grand Total | 6 900 000 | ||
| 6 |
| A | B | C | D | |
|---|---|---|---|---|
| 1 | City | Product | Amount | |
| 2 | Tashkent | Tea | 1 200 000 | |
| 3 | Tashkent Total | 1 200 0001 | ||
| 4 | Samarkand | Rice | 2 250 000 | |
| 5 | Samarkand Total | 2 250 000 | ||
| 6 | Tashkent | Sugar | 780 000 | |
| 7 | Tashkent Total | 780 0002 | ||
| 8 |
Manual grouping (Group)
You can build an outline without total rows too. Say you want to hide the monthly columns (Jan, Feb, Mar) and keep only the quarter total:
- Select the rows or columns to hide.
- Click Данные → Group or press Shift + Alt + →.
- A − button appears on the left (or above) — click it and the group collapses.
To undo: Ungroup or Shift + Alt + ←. Groups can be nested — up to 8 levels.
Pro level: why SUBTOTAL and not SUM
There’s a reason Excel writes SUBTOTAL(9,…) rather than SUM in total rows: SUBTOTAL ignores other SUBTOTALs. So the grand total =ПРОМЕЖУТОЧНЫЕ.ИТОГИ(9;C2:C10) covers the whole column, subtotals included, without counting them twice. =СУММ(C2:C10) would count every amount twice and return 13,800,000.
A few more techniques:
- Several functions. Run Subtotal a second time with Use function set to Average and untick Replace current subtotals — each group gets both a sum and an average.
- One group per page. Page break between groups prints each city on its own page.
- Removing. Данные → Subtotal → Remove All deletes total rows and the outline, keeping the original data.
- Doesn’t work in a Table. If the Subtotal button is greyed out, your data is in a Table: Table Design → Convert to Range.
Try it in the simulator
The table is sorted by city and the total rows are ready. Type =ПРОМЕЖУТОЧНЫЕ.ИТОГИ(9;C2:C3) in C4, =ПРОМЕЖУТОЧНЫЕ.ИТОГИ(9;C5:C6) in C7 and =ПРОМЕЖУТОЧНЫЕ.ИТОГИ(9;C8:C9) in C10, then compare each city total with Sum on the status bar.
| A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | City | Product | Amount | |||||||||||||||||||||
| 2 | Bukhara | Flour | 1650000 | |||||||||||||||||||||
| 3 | Bukhara | Bread | 480000 | |||||||||||||||||||||
| 4 | Bukhara Total | |||||||||||||||||||||||
| 5 | Samarkand | Rice | 2250000 | |||||||||||||||||||||
| 6 | Samarkand | Oil | 540000 | |||||||||||||||||||||
| 7 | Samarkand Total | |||||||||||||||||||||||
| 8 | Tashkent | Tea | 1200000 | |||||||||||||||||||||
| 9 | Tashkent | Sugar | 780000 | |||||||||||||||||||||
| 10 | Tashkent Total | |||||||||||||||||||||||
| 11 | ||||||||||||||||||||||||
| 12 | ||||||||||||||||||||||||
| 13 | ||||||||||||||||||||||||
| 14 |
Has ExcelLab been useful?
Support the project and help us release new lessons and exercises.