Excel tutorial
/

PivotTables

Advanced

Calculated fields in a PivotTable: formulas, examples and limitations

Add a calculation to a PivotTable without touching the source: average price, bonus, margin — and see where a calculated field silently goes wrong.

Your PivotTable has amount and quantity, but the manager asks: “What is the average price in each region?” You could add a column to the source, but sometimes the data belongs to another department or must not be changed.

A Calculated Field is a new field that lives inside the PivotTable. Its formula is built from other fields: =Amount/Qty, =Amount*0,05. It appears in the field list like a regular column and goes into Values.

But it has one crucial property — it calculates on sums, not row by row. Miss that and your report will be silently wrong. Details below.

Книга1 - Excel
—☐✕
D4fx4611111,11
ABCDE
1Row LabelsSum of AmountSum of QtySum of Price
2Bukhara26 600 00055 320 000
3Samarkand20 500 00063 416 667
4Tashkent41 500 00094 611 111
5Grand Total88 600 000204 430 000
6
Готово
Price = Amount / Qty — there is no such column in the source, it is calculated inside the PivotTable

Adding a calculated field

1

Click any cell in the PivotTable. PivotTable Analyze → Fields, Items & Sets → Calculated Field....

2

In the Insert Calculated Field dialog type the new field’s Name: Price. In Formula delete the 0, then after = double-click Amount in the Fields list, type / and double-click Qty.

Книга1 - Excel
—☐✕
A2fxBukhara
ABCD
1Row LabelsSum of AmountSum of Qty
2Bukhara26 600 0005
3Samarkand20 500 0006
4Tashkent41 500 0009
5Grand Total88 600 00020
6
Готово

3

Click Add, then OK. Price appears in the field list and is placed in Values automatically as Sum of Price. Format it via Value Field Settings → Number Format (the result above).

4

If a field name contains a space, wrap it in apostrophes in the formula: ='Sales amount'/Qty. Insert fields by double-clicking them in the list and Excel adds the apostrophes for you.

Key point: the formula runs on totals, not on rows

Excel first adds up the fields for each group, then applies the formula to those totals. For Tashkent: total Amount 41,500,000, total Qty 9 → Price = 41,500,000 / 9 = 4,611,111. That’s correct — a weighted average price.

But a formula with multiplication breaks. Suppose the source has Price and Qty columns but no Amount. A calculated field =Price*Qty does not multiply price by quantity on each row — it multiplies the sum of prices by the sum of quantities:

Книга1 - Excel
—☐✕
D5fx=СУММ(B2:B3)*СУММ(C2:C3)
ABCDE
1ProductPriceQtyAmount
2Laptop8 500 000325 500 000
3Printer3 200 00026 400 000
4Correct total31 900 000
5Calculated Field58 500 0001
6
Готово
Tashkent: real revenue is 31,900,000, but the =Price*Qty field shows (8.5M + 3.2M) × 5 = 58,500,000
Книга1 - Excel
—☐✕
C5fx8860000
ABCD
1Row LabelsSum of AmountSum of Bonus
2Bukhara26 600 0002 660 000
3Samarkand20 500 0001 025 000
4Tashkent41 500 0004 150 000
5Grand Total88 600 0008 860 0001
6Sum of bonuses7 835 000
7
Готово
The Grand Total bonus (8,860,000) doesn’t equal the sum of the rows (7,835,000)

Limitations of calculated fields

  • Sums only. The formula always works on the SUM of each field — even if you pick Average or Count in Values.
  • No cell references. =Amount*B1, named ranges and other sheets don’t work — only field names and constants: =Amount*0,12.
  • Can’t count rows. If you need to divide by the number of sales, add a helper column of 1s to the source and use it as a field.
  • Text fields can’t take part in arithmetic.
  • Data Model PivotTables have no calculated fields — use DAX measures (Power Pivot) there.

Simple rule: ratios (Amount/Qty, margin = (Amount−Cost)/Amount) come out right in a calculated field. Products and conditions should be calculated row by row in the source.

Pro level: calculated items, editing and the formula list

A Calculated Item adds a new item inside a field. For example, in Region — “Regions” = Bukhara + Samarkand. But it’s risky: the Grand Total counts Bukhara and Samarkand twice, it doesn’t work at all in a grouped field, and it noticeably slows down a big PivotTable. Usually plain grouping is enough instead.

Editing and deleting. Open the same Insert Calculated Field dialog and pick the field from the Name list — the button changes to Modify; click Delete to remove it.

Documenting. PivotTable Analyze → Fields, Items & Sets → List Formulas — Excel lists every calculated field and item formula of the PivotTable on a new sheet. Very handy before handing a report over to someone else.

Try it in the simulator

Check the calculated field with a formula: type =СУММЕСЛИМН($C$2:$C$8;$A$2:$A$8;D2)/СУММЕСЛИМН($B$2:$B$8;$A$2:$A$8;D2) in E2 and fill it down to E4. Tashkent: 4611111.11 — the same as Price in the PivotTable.

Книга1 - Excel
—☐✕
Буфер обмена
Шрифт
Выравнивание
Число
Стили
Ячейки
Редактирование
✕✓fx
ABCDEFGHIJKLMNOPQRSTUVWX
1RegionQtyAmountRegionPrice
2Tashkent325500000Bukhara
3Samarkand512000000Samarkand
4Tashkent26400000Tashkent
5Bukhara217000000
6Samarkand18500000
7Tashkent49600000
8Bukhara39600000
9
10
11
12
Лист1
Готово

Has ExcelLab been useful?

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

Support us
Previous

65 / 154