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.

Intermediate 18 min read

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).

ABCD
1RegionProductRepAmount
2NorthLaptopAnna4750
3NorthMonitorAnna1890
4SouthLaptopBruno3800
5SouthMouseBruno360
6EastLaptopChen5700
7EastMonitorChen945
8NorthMouseDina240

Seven sales records in a table named Sales. Real lists have thousands of rows; the method is identical.

Create a PivotTable

  1. Click any cell in the data.
  2. Choose Insert › Tables › PivotTable (in Microsoft 365 choose From Table/Range).
  3. Check the Table/Range (Sales) and choose New Worksheet. Click OK.
  4. 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.
  5. Drag Region to Rows and Amount to Values. The summary appears instantly.
AB
1Row LabelsSum of Amount
2East6645
3North6880
4South4160
5Grand Total17685

Region in Rows, Amount in Values. The Grand Total equals the sum of the source amounts.

Tip. Ticking a checkbox in the field list also works: text fields go to Rows and number fields to Values. Dragging gives you control over the area.

The four areas

AreaWhat it doesExample
RowsOne row per unique itemRegions down the side
ColumnsOne column per unique itemProducts across the top
ValuesThe numbers to summariseSum of Amount
FiltersA drop-down above the table that filters the whole reportShow 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.

ABCDE
1Sum of AmountLaptopMonitorMouseGrand Total
2East57009456645
3North475018902406880
4South38003604160
5Grand Total14250283560017685

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.

Watch out. If a PivotTable shows Count of Amount when you expected a sum, the Amount column contains text or blank cells somewhere in the source. Fix the source data (convert text to numbers) and refresh, or change the summary to Sum manually.

Show values as a percentage

  1. Drag Amount into Values a second time. You now have Sum of Amount2.
  2. Right-click a number in that column and choose Show Values As › % of Grand Total.
  3. Rename the header by clicking it and typing Share.
  4. 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.

Tip. If Group is greyed out or says 'Cannot group that selection', the date column contains text or blanks. Clean the source, refresh, and try again.

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.

Watch out. If the source is a plain range, rows added below it are not included even after refresh. Either change the range with PivotTable Analyze › Change Data Source, or, better, base the PivotTable on an Excel table.

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).

Note. PivotTables work in all versions on Windows and Mac. In Microsoft 365 for the web you can create and edit PivotTables in current versions. Automatic date grouping arrived in Excel 2016 and can be turned off in File › Options › Data. Microsoft 365 also has the formula functions PIVOTBY and GROUPBY, which build summaries that recalculate automatically.

Check yourself

1. Which area of the field list holds the numbers you want to summarise?

2. A PivotTable shows 'Count of Amount' instead of a sum. What is the likely cause?

3. You changed values in the source. What do you need to do?

4. What happens when you double-click a value in a PivotTable?

5. North's sales are 6,880 out of a total of 17,685. What does % of Grand Total show for North?