Summarising data with PivotTables
Summarise thousands of rows in a few clicks with PivotTables: totals by region, counts by product, months across columns, filters and slicers, then refresh when new data arrives.
π― By the end of this lesson you will be able to:
- Create a PivotTable from a table of data
- Arrange fields in Rows, Columns, Values and Filters to answer questions
- Change the summary (sum, count, average), group dates and refresh
Outline
What you'll learn and why it matters
A PivotTable summarises a big table without a single formula: *total sales by region*, *units of each product per month*, *number of orders per salesperson*. You drag fields around and the summary rearranges itself instantly. Analysts call it the most powerful feature in Excel, and it is the first thing many interviewers ask about.
Create a PivotTable
- Click any cell in the Sales data (ideally formatted as a table, lesson 8), after adding a Total column (
=Units*Price, using XLOOKUP for the price as in lesson 6). - Choose Insert β PivotTable. Excel selects the whole table. Choose New worksheet and click OK.
- A blank PivotTable appears with the PivotTable Fields pane on the right, listing every column heading.
The pane has four boxes. Drag field names into them (or tick a field and let Excel choose):
| Box | What it does | Example |
|---|---|---|
| Rows | One row in the summary per different value | Region |
| Columns | One column per different value | Month |
| Values | The numbers to summarise (Sum, Count, Averageβ¦) | Total |
| Filters | Show only some data | Salesperson = Asha |
Total sales by region
Drag Region to Rows, and Total to Values (it shows *Sum of Total*). Drag Order ID to Values as well: because it is text, Excel counts it (*Count of Order ID*). Here is the result for the practice workbook's 48 orders:
Worksheet: PivotTable
| Row | A | B | C |
|---|---|---|---|
| 1 | Row Labels | Sum of Total | Count of Order ID |
| 2 | East | 16,190 | 11 |
| 3 | North | 30,890 | 13 |
| 4 | South | 14,860 | 9 |
| 5 | West | 28,370 | 15 |
| 6 | Grand Total | 90,310 | 48 |
That is a summary of 48 rows in about ten seconds, and it would be just as quick for 48,000.
Rows and columns: a cross-table
Put Product in Rows, Date in Columns and Units in Values. Excel groups the dates by month automatically (in Excel for the web, right-click a date and choose Group if it does not). For January to March:
Worksheet: PivotTable
| Row | A | B | C | D | E |
|---|---|---|---|---|---|
| 1 | Sum of Units | Jan | Feb | Mar | Grand Total |
| 2 | Notebook | 11 | 17 | 12 | 40 |
| 3 | Pen set | 12 | 5 | 9 | 26 |
| 4 | Backpack | 2 | 3 | 2 | 7 |
| 5 | Water bottle | 0 | 17 | 3 | 20 |
| 6 | Desk lamp | 4 | 0 | 0 | 4 |
| 7 | Sketchbook | 14 | 11 | 11 | 36 |
Changing what is shown
| To⦠| Do this |
|---|---|
| Show an average instead of a sum | Click the field in Values β Value Field Settings (or Summarize Values By) β Average |
| Show percentages of the total | Value Field Settings β Show Values As β % of Grand Total |
| Sort largest first | Right-click a number in the column β Sort β Sort Largest to Smallest |
| Filter to one salesperson | Drag Salesperson to Filters, then pick a name above the PivotTable |
| Click-to-filter buttons | Insert β Slicer (desktop Excel and Microsoft 365) shows a button per value |
| See the rows behind a number | Double-click the number (desktop Excel): a new sheet lists the matching orders |
Checking a PivotTable with formulas
A good analyst double-checks important numbers. SUMIFS and COUNTIFS (lesson 5) give the same answers as a PivotTable, so you can check one against the other:
Worksheet: Check
| Row | A | B | C | D | E | F | G | H | I | J |
|---|---|---|---|---|---|---|---|---|---|---|
| 1 | Region | Salesperson | Product | Units | Price | Total | Region | Sum of Total | Count | |
| 2 | West | Asha | Sketchbook | 11 | 300 | 3300 | North | 8880 | 4 | |
| 3 | North | Meera | Pen set | 4 | 250 | 1000 | South | 1320 | 1 | |
| 4 | West | Ravi | Sketchbook | 3 | 300 | 900 | East | 3240 | 2 | |
| 5 | North | Sara | Notebook | 9 | 120 | 1080 | West | 8200 | 3 | |
| 6 | East | Ravi | Notebook | 2 | 120 | 240 | Total | 21640 | 10 | |
| 7 | North | Meera | Pen set | 8 | 250 | 2000 | ||||
| 8 | East | Meera | Backpack | 2 | 1500 | 3000 | ||||
| 9 | North | Asha | Desk lamp | 4 | 1200 | 4800 | ||||
| 10 | South | Kofi | Notebook | 11 | 120 | 1320 | ||||
| 11 | West | Ravi | Water bottle | 10 | 400 | 4000 |
Formulas (green cells)
- F2 =D2*E2 β 3300
- I2 =SUMIFS($F$2:$F$11,$A$2:$A$11,H2) β 8880
- J2 =COUNTIFS($A$2:$A$11,H2) β 4
- F3 =D3*E3 β 1000
- I3 =SUMIFS($F$2:$F$11,$A$2:$A$11,H3) β 1320
- J3 =COUNTIFS($A$2:$A$11,H3) β 1
- F4 =D4*E4 β 900
- I4 =SUMIFS($F$2:$F$11,$A$2:$A$11,H4) β 3240
- J4 =COUNTIFS($A$2:$A$11,H4) β 2
- F5 =D5*E5 β 1080
- I5 =SUMIFS($F$2:$F$11,$A$2:$A$11,H5) β 8200
- J5 =COUNTIFS($A$2:$A$11,H5) β 3
- F6 =D6*E6 β 240
- I6 =SUM(I2:I5) β 21640
- J6 =SUM(J2:J5) β 10
- F7 =D7*E7 β 2000
- F8 =D8*E8 β 3000
- F9 =D9*E9 β 4800
- F10 =D10*E10 β 1320
- F11 =D11*E11 β 4000
Practice
Guided exercise
Sales by salesperson
In the practice workbook, create a PivotTable showing each salesperson's total sales, largest first.
- Insert β PivotTable from the Sales data (with the Total column added).
- Drag Salesperson to Rows and Total to Values.
- Right-click a number β Sort Largest to Smallest.
Show the solution
Worksheet: PivotTable
| Row | A | B |
|---|---|---|
| 1 | Row Labels | Sum of Total |
| 2 | Ravi | 27,080 |
| 3 | Asha | 19,850 |
| 4 | Kofi | 14,850 |
| 5 | Sara | 14,290 |
| 6 | Meera | 14,240 |
| 7 | Grand Total | 90,310 |
How to get there: Salesperson in Rows gives one row per person; Total in Values sums their orders. Sorting makes the ranking easy to read. The Grand Total is the same as the total of all 48 orders, which is a quick check that nothing was missed.
Your turn
Average order by product
Change the PivotTable to show the average order total for each product. Which product has the highest average order?
Show the solution
Worksheet: PivotTable
| Row | A | B |
|---|---|---|
| 1 | Row Labels | Average of Total |
| 2 | Backpack | 3,000 |
| 3 | Desk lamp | 2,600 |
| 4 | Water bottle | 2,171 |
| 5 | Sketchbook | 1,950 |
| 6 | Pen set | 1,893 |
| 7 | Notebook | 754 |
How to get there: Put Product in Rows and Total in Values, then use Value Field Settings β Average. Backpacks have the highest average order because each one costs 1,500. (The averages here are rounded to whole rupees.)
Common mistakes
Forgetting to refresh
You see: The PivotTable shows old numbers
Fix: Right-click β Refresh after changing data.
Blank or merged headings in the data
You see: Excel refuses to create the PivotTable or fields have odd names
Fix: Give every column a unique, single-row heading.
Numbers stored as text
You see: Values show Count instead of Sum
Fix: Fix the data so numbers are real numbers (they align right).
Typing over PivotTable cells
You see: Excel warns you cannot change that part
Fix: Keep calculations outside the PivotTable, or use its own settings.
Recap
- Insert β PivotTable summarises a table without formulas.
- Rows and Columns set the layout; Values holds the numbers; Filters narrows the data.
- Value Field Settings switches between Sum, Count, Average and % of total; dates can be grouped by month.
- Refresh after data changes, and check key numbers with SUMIFS and COUNTIFS.
Key terms
- PivotTable
- An interactive summary of a table, built by dragging fields into Rows, Columns, Values and Filters.
- Field
- A column of the source data, shown by its heading in the PivotTable Fields pane.
- Refresh
- Recalculating a PivotTable after its source data changes.
Check your understanding
Answer all 4 questions, then check your answers to see an explanation for each one.
1. Which box gives one row in the summary for each region?
2. You drag a text field such as Order ID into Values. What does Excel show?
3. You added new orders but the PivotTable totals did not change. Why?
4. How can you show each region's share of total sales as a percentage?
Mark this lesson complete
Finished this lesson?
When you have worked through the examples and exercises, mark it complete to save your progress.