Excel tutorial
/

Data analysis

Intermediate

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.

Книга1 - Excel
—☐✕
C4fx=ПРОМЕЖУТОЧНЫЕ.ИТОГИ(9;C2:C3)
ABCD
1CityProductAmount
2BukharaFlour1 650 000
3BukharaBread480 000
4Bukhara Total2 130 000
5SamarkandRice2 250 000
6SamarkandOil540 000
7Samarkand Total2 790 000
8TashkentTea1 200 000
9TashkentSugar780 000
10Tashkent Total1 980 000
11Grand Total6 900 000
12
Готово
The result: a total row under each city and a grand total at the end (C11 holds =SUBTOTAL(9,C2:C10))

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.

Книга1 - Excel
—☐✕
ФайлГлавнаяВставкаРазметка страницыФормулыДанныеРецензированиеВидСправка
Получить данныеОбновить все
Получить данные
СортировкаФильтр
Сортировка и фильтр
Текст по столбцамУдалить дубликатыПроверка данных
Работа с данными
A2fxBukhara
ABCD
1CityProductAmount
2Bukhara1Flour1 650 000
3BukharaBread480 000
4SamarkandRice2 250 000
5SamarkandOil540 000
6TashkentTea1 200 000
7TashkentSugar780 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.

Книга1 - Excel
—☐✕
ФайлГлавнаяВставкаРазметка страницыФормулыДанныеРецензированиеВидСправка
Получить данныеОбновить все
Получить данные
СортировкаФильтр
Сортировка и фильтр
Текст по столбцамУдалить дубликатыПроверка данных
Работа с данными
A2fxBukhara
ABCD
1CityProductAmount
2BukharaFlour1 650 000
3BukharaBread480 000
4SamarkandRice2 250 000
5SamarkandOil540 000
6TashkentTea1 200 000
7TashkentSugar780 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.

Книга1 - Excel
—☐✕
A1fxCity
ABCD
1CityProductAmount
2Bukhara Total2 130 000
3Samarkand Total2 790 000
4Tashkent Total1 980 000
5Grand Total6 900 000
6
ГотовоСреднее: 3450000Количество: 11Сумма: 13800000
Level 2: detail rows are collapsed, only city totals and the grand total are visible
Книга1 - Excel
—☐✕
fx
ABCD
1CityProductAmount
2TashkentTea1 200 000
3Tashkent Total1 200 0001
4SamarkandRice2 250 000
5Samarkand Total2 250 000
6TashkentSugar780 000
7Tashkent Total780 0002
8
Готово
An unsorted table: Tashkent gets two separate totals (1 and 2) — the real total of 1,980,000 appears nowhere

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:

  1. Select the rows or columns to hide.
  2. Click Данные → Group or press Shift + Alt + →.
  3. 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.

Книга1 - Excel
—☐✕
Буфер обмена
Шрифт
Выравнивание
Число
Стили
Ячейки
Редактирование
✕✓fx
ABCDEFGHIJKLMNOPQRSTUVWX
1CityProductAmount
2BukharaFlour1650000
3BukharaBread480000
4Bukhara Total
5SamarkandRice2250000
6SamarkandOil540000
7Samarkand Total
8TashkentTea1200000
9TashkentSugar780000
10Tashkent Total
11
12
13
14
Лист1
Готово

Has ExcelLab been useful?

Support the project and help us release new lessons and exercises.

Support us
Previous

45 / 154