Your first PivotTable

Every Friday, Maria from the sales team works out how much revenue each manager brought in that week. A week adds up to forty orders:

fx
A
B
C
D
E
F
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
Manager
City
Revenue, $
Emma
Denver
14200
Leo
Boston
13200
Emma
Boston
1500
Ben
Austin
13400
Leo
Boston
15000
Emma
Austin
3800
Leo
Austin
6600
Olivia
Austin
4500
Ben
Denver
7900
Ben
Austin
12900
Ben
Denver
11500
Emma
Denver
4800
Emma
Austin
8800
Ben
Austin
3200
Olivia
Boston
6700
Ben
Boston
5600
Emma
Boston
8700
Emma
Boston
1700
Emma
Austin
11200
Olivia
Denver
12700
Leo
Denver
3000
Olivia
Boston
6400
Leo
Austin
10700
Leo
Boston
7200
Leo
Denver
12800
Emma
Denver
2300
Leo
Denver
7400
Ben
Boston
11200
Olivia
Austin
5300
Ben
Boston
2400
Olivia
Denver
7800
Emma
Austin
2400
Emma
Austin
14100
Ben
Denver
8300
Emma
Boston
2700
Olivia
Denver
6000
Ben
Austin
4900
Leo
Denver
10500
Ben
Boston
2100
Ben
Boston
5900
Sheet1

Maria filters the table by Emma, adds up her orders and copies the total into a separate small table. Then she does the same for Ben, Olivia and Leo. Half an hour for four numbers, and she starts over if an order turns out to have a mistake.

Excel can build this kind of report by itself. It's called a PivotTable: a short table of totals that Excel calculates from a long one.

You could build the same report with SUMIF formulas, one per manager. But then you'd have to make the list of managers yourself and write new formulas for every new question. A PivotTable finds all the managers in the table by itself, and you change the question with a single checkbox.

A question turns into fields

A PivotTable is built from fields. A field is a column of the source table, and its name comes from the header: "Manager", "City", "Revenue, $".

You arrange fields in the PivotTable Fields pane. It has a list of fields with checkboxes and four areas: Filters, Rows, Columns and Values. For your first report, Rows and Values are enough.

To build a report, split the question into two parts:

  • what to group by: "each manager". This field goes into the Rows area, and each manager gets a row of their own in the report;
  • what to calculate: "revenue". This field goes into Values, and Excel adds up the revenue within each row.
How much revenue did each manager bring in?
How much revenue came from each city?
How much revenue did each category make?
ManagerCityCategoryRevenue, $
EmmaBostonElectronics12,400
BenDenverClothing3,200
EmmaAustinElectronics8,700
OliviaBostonClothing5,100
OliviaDenverElectronics4,800
BenBostonClothing2,900
LeoAustinElectronics15,300
EmmaDenverClothing6,100
LeoBostonElectronics7,400
BenAustinClothing3,900
EmmaBostonClothing4,400
LeoDenverElectronics9,800
Rows
Manager
Values
Sum of Revenue, $
Row LabelsSum of Revenue, $
Ben10,000
Emma31,600
Leo32,500
Olivia9,900
Grand Total84,000
Row LabelsSum of Revenue, $
Austin27,900
Boston32,200
Denver23,900
Grand Total84,000
Row LabelsSum of Revenue, $
Clothing25,600
Electronics58,400
Grand Total84,000

In the diagram, the same twelve orders give three different reports, and the only thing that changes is the field in Rows.

Two checkboxes instead of formulas

Build Maria's report right on her table. You don't need to select the whole table: click any of its cells, and Excel finds where the table starts and ends by itself. After you click PivotTable, Excel opens the Create PivotTable dialog with the table range and the report location already filled in, so all that's left is to click OK. An empty frame for the future report appears on the sheet, with the field list next to it. There, Excel sends a text field to Rows and a number field to Values by itself.

Create a PivotTable by manager: Insert → PivotTable → OK, then check “Manager” and “Revenue, $” in the field list
fx
A
B
C
D
E
F
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
Manager
City
Revenue, $
Emma
Denver
14200
Leo
Boston
13200
Emma
Boston
1500
Ben
Austin
13400
Leo
Boston
15000
Emma
Austin
3800
Leo
Austin
6600
Olivia
Austin
4500
Ben
Denver
7900
Ben
Austin
12900
Ben
Denver
11500
Emma
Denver
4800
Emma
Austin
8800
Ben
Austin
3200
Olivia
Boston
6700
Ben
Boston
5600
Emma
Boston
8700
Emma
Boston
1700
Emma
Austin
11200
Olivia
Denver
12700
Leo
Denver
3000
Olivia
Boston
6400
Leo
Austin
10700
Leo
Boston
7200
Leo
Denver
12800
Emma
Denver
2300
Leo
Denver
7400
Ben
Boston
11200
Olivia
Austin
5300
Ben
Boston
2400
Olivia
Denver
7800
Emma
Austin
2400
Emma
Austin
14100
Ben
Denver
8300
Emma
Boston
2700
Olivia
Denver
6000
Ben
Austin
4900
Leo
Denver
10500
Ben
Boston
2100
Ben
Boston
5900
Sheet1
You can check the boxes in any order: Excel sends a text field to Rows and a number field to Values by itself.

The report doesn't follow the table

A PivotTable remembers the numbers at the moment it's created and doesn't follow the table by itself. If you fix an order in the table, the report keeps showing the old total. To recalculate it, click the report and on the PivotTable Analyze tab click Refresh.

You don't change the report cells by hand. A wrong number is fixed in the source table, and then the report is refreshed. The same goes for messy names: the PivotTable treats "Boston" and "Boston " with a space at the end as two different cities and gives them two rows. Clean such names with the TRIM function and click Refresh.

Refresh recalculates only the rows the report was built from. An order added below the table won't make it into the report: to include it, create the PivotTable again.

Maria's Friday half hour has shrunk to two checkboxes. And a mistake in an order no longer means "count everything again": just fix the number in the table and click Refresh.