Excel course · Lesson 14 of 34
PivotTables: summarise thousands of rows in seconds
Build PivotTables step by step: rows, columns, values and filters, Sum vs Count, % of total, grouping dates, refreshing and GETPIVOTDATA.
A PivotTable summarises a large list without a single formula. Drag a field to Rows, another to Values, and Excel produces totals by region, by product, by month, in seconds. Drag fields around and the summary reorganises itself: that rotating is the pivot in PivotTable. If you work with lists of sales, expenses, tickets or timesheets, this is the most valuable tool in Excel to learn.
Prepare the source data
PivotTables need a clean list: one header row with unique names, one record per row, no blank rows, no subtotal rows and no merged cells. Ideally the source is an Excel table, so new rows are picked up on refresh (Excel tables and structured references).
| A | B | C | D | |
|---|---|---|---|---|
| 1 | Region | Product | Rep | Amount |
| 2 | North | Laptop | Anna | 4750 |
| 3 | North | Monitor | Anna | 1890 |
| 4 | South | Laptop | Bruno | 3800 |
| 5 | South | Mouse | Bruno | 360 |
| 6 | East | Laptop | Chen | 5700 |
| 7 | East | Monitor | Chen | 945 |
| 8 | North | Mouse | Dina | 240 |
Seven sales records in a table named Sales. Real lists have thousands of rows; the method is identical.
Create a PivotTable
- Click any cell in the data.
- Choose Insert › Tables › PivotTable (in Microsoft 365 choose From Table/Range).
- Check the Table/Range (
Sales) and choose New Worksheet. Click OK. - An empty PivotTable appears on the left and the PivotTable Fields pane on the right. The pane lists every column of the source at the top and four areas at the bottom: Filters, Columns, Rows and Values.
- Drag Region to Rows and Amount to Values. The summary appears instantly.
| A | B | |
|---|---|---|
| 1 | Row Labels | Sum of Amount |
| 2 | East | 6645 |
| 3 | North | 6880 |
| 4 | South | 4160 |
| 5 | Grand Total | 17685 |
Region in Rows, Amount in Values. The Grand Total equals the sum of the source amounts.
The four areas
| Area | What it does | Example |
|---|---|---|
| Rows | One row per unique item | Regions down the side |
| Columns | One column per unique item | Products across the top |
| Values | The numbers to summarise | Sum of Amount |
| Filters | A drop-down above the table that filters the whole report | Show only rep Anna |
Drag Product to Columns and you get a cross-tab: regions down, products across, the amount in each intersection. North / Laptop shows 4,750; East / Monitor shows 945; South / Monitor is empty because there were no such sales.
| A | B | C | D | E | |
|---|---|---|---|---|---|
| 1 | Sum of Amount | Laptop | Monitor | Mouse | Grand Total |
| 2 | East | 5700 | 945 | 6645 | |
| 3 | North | 4750 | 1890 | 240 | 6880 |
| 4 | South | 3800 | 360 | 4160 | |
| 5 | Grand Total | 14250 | 2835 | 600 | 17685 |
Region in Rows, Product in Columns.
Summarise by Count, Average, Max …
By default numbers are summed and text is counted. To change it, click the field in the Values area (or right-click a value in the PivotTable) and choose Value Field Settings › Summarize Values By: Sum, Count, Average, Max, Min, Product and others. For example Count of Amount by region shows how many sales each region made: East 2, North 3, South 2.
Show values as a percentage
- Drag Amount into Values a second time. You now have Sum of Amount2.
- Right-click a number in that column and choose Show Values As › % of Grand Total.
- Rename the header by clicking it and typing
Share. - North now shows 38.9%, East 37.6%, South 23.5%.
Other useful options in Show Values As: % of Column Total, % of Parent Row Total, Difference From (for month-on-month change), Running Total In and Rank Largest to Smallest.
Number formats in PivotTables
Do not format PivotTable cells with the Home tab; the format may be lost on refresh. Instead open Value Field Settings › Number Format and choose a format there. It sticks to the field.
Grouping dates and numbers
When you put a date field in Rows, Excel 2016 and later group it automatically into Years, Quarters and Months. To control grouping yourself, right-click a date in the PivotTable and choose Group, then select Months and Years (select both, or January 2025 and January 2026 are merged). Number fields can be grouped into bands the same way, for example order sizes 0–999, 1000–1999 and so on.
Sorting, filtering and drilling down
- Click the arrow next to Row Labels to sort or filter, including Value Filters › Top 10 to show the best customers.
- Right-click a value › Sort › Sort Largest to Smallest to rank regions by sales.
- Double-click any value to drill down: Excel creates a new sheet listing exactly the source rows behind that number. Double-clicking North's total lists the three North sales.
- Slicers and timelines give clickable filters (PivotCharts, slicers and timelines).
Refreshing
PivotTables do not update automatically when the source changes. After editing the data, right-click the PivotTable and choose Refresh, or press Alt+F5 (Mac: PivotTable Analyze › Refresh). Data › Queries & Connections › Refresh All (Ctrl+Alt+F5) refreshes every PivotTable and query in the workbook. To refresh whenever the file opens, use PivotTable Analyze › Options › Data › Refresh data when opening the file.
Layout and design
- Design › Report Layout › Show in Tabular Form puts each Rows field in its own column, which is easier to read and to copy elsewhere. Add Repeat All Item Labels to fill every row.
- Design › Subtotals and Grand Totals turn totals on or off.
- Design › PivotTable Styles changes colours; tick Banded Rows for readability.
- PivotTable Analyze › Options › Layout & Format › For empty cells show lets you show 0 instead of blanks.
GETPIVOTDATA
If you type = and click a cell inside a PivotTable, Excel writes a GETPIVOTDATA formula such as =GETPIVOTDATA("Amount",$A$3,"Region","North") instead of =B5. It keeps returning North's total even if the layout changes and North moves to another row. If you prefer plain references, turn this off with PivotTable Analyze › Options › Generate GetPivotData (Windows).
Calculated fields
PivotTable Analyze › Calculations › Fields, Items & Sets › Calculated Field adds a formula field, for example Commission = Amount * 0.05. Calculated fields work on sums, so averages and ratios can behave unexpectedly; for serious calculations use the Data Model and DAX measures (Power Pivot and the Data Model: relationships and DAX measures).
Check yourself
1. Which area of the field list holds the numbers you want to summarise?
Values holds the measure: Sum of Amount, Count of Orders, and so on.
2. A PivotTable shows 'Count of Amount' instead of a sum. What is the likely cause?
Fields with text or blanks default to Count.
3. You changed values in the source. What do you need to do?
PivotTables keep a cache and update only on Refresh.
4. What happens when you double-click a value in a PivotTable?
This is called drill-down or Show Details.
5. North's sales are 6,880 out of a total of 17,685. What does % of Grand Total show for North?
6,880 / 17,685 = 0.389, shown as 38.9%.