Confident CellsExcel practice Start free

PivotTables: calculated fields: practice exercises

Calculated Field: Profit = Sales − Cost, VAT at 20%, price per item, margin as a percentage, names with spaces, Modify, IF. 8 exercises on real-looking data, each checked as you go. The full lesson is part of Pro.

In the lesson

This lesson has a PivotTable builder like Excel's: drag fields into Rows, Columns and Values, and each task is checked as you go.

Open the PivotTables: calculated fields lesson

How it works

A calculated field is a new field made from a formula over the others, such as Profit = Sales − Cost. Make one with PivotTable Analyse (Pivot Table Analyse on a Mac), Fields, Items & Sets, Calculated Field. Excel puts it in Values, and in the field list.

It always adds up first: for each line of the PivotTable it totals Sales and Cost, then works out the formula on the totals. That's right for a profit, and it's how a price per item should be worked out, but it surprises people who expect it to add up the rows.

Make a calculated field

The Leeds branch sold £12,400 and its costs were £9,150, so its profit is £12,400 − £9,150 = £3,250.

Row LabelsSum of SalesSum of Profit
Derby108002950
Leeds124003250
Grand Total232006200
  1. PivotTable Analyse, Fields, Items & Sets, Calculated Field.
  2. Name: Profit. Formula: =Sales-Cost. Double-click a field in the list to put it in the formula.
  3. Add, then OK. Excel puts Sum of Profit in Values.

Use the fields' names, never cells like C2: a PivotTable formula can't use cell references.

It adds up first

Two orders: 10 items for £50 (£5 each) and 2 items for £30 (£15 each). The average price per item is £80 ÷ 12 = £6.67, not the average of £5 and £15, which is £10.

A calculated field =Sales/Items adds up first: Sales £80, Items 12, then £80 ÷ 12 = £6.67. That's the right answer here.

Totals work the same way. The Grand Total line totals Sales and Items for all the data, then divides, so it isn't the average of the lines above. With an IF, such as a bonus for sales over £20,000, the Grand Total tests the total sales, not each branch.

Spaces, brackets and changes

A name with a space in it goes in single quotes: ='Card sales'+'Cash sales'. Choose the field and press Insert Field, and Excel adds the quotes.

Use brackets as in any formula. A margin is =(Sales-Cost)/Sales: £3,250 ÷ £12,400 = 26.21%. Then set its Number Format to Percentage in Value Field Settings.

To change one, open Calculated Field again, choose it in the Name box, edit the formula, and press Modify. Delete removes it. A calculated field can only go in Values, and it's always a Sum.

What you'll practise

  1. Add a calculated field called Profit: the sales take away the cost, =Sales-Cost.
  2. The sales figures don't include VAT. Add a calculated field called VAT that works out 20% of Sales.
  3. What did each branch get per item sold? Add a calculated field called Price per item: the sales divided by the number of items.
  4. Add a calculated field called Margin: the profit as a share of the sales, (Sales − Cost) ÷ Sales. Then give it the Percentage number format.
  5. Add a calculated field called Takings: the card sales plus the cash sales. The names have spaces in them, so in the formula each goes in single quotes. (Insert Field does that for you.)
  6. Profit should take off the delivery costs too. Change the Profit field's formula to =Sales-Cost-Delivery: choose Profit in the Name box, change the formula, then Modify.
  7. A branch whose sales are over £5,000 gets a bonus of 5% of its sales; the rest get nothing. Add a calculated field called Bonus: =IF(Sales>5000,Sales*5%,0).
  8. Make a PivotTable showing just the profit per item for each month: a calculated field called Profit per item, (Sales − Cost) ÷ Items, with Month in Rows and nothing else in Values.