CodeMIRAI
0 XP

PivotTables

2 min read Quiz included

A PivotTable summarises a table of data, totals by region or counts by month, with no formulas, just by dragging fields. It's one of Excel's most powerful features, and one of the easiest to learn.

The data

PivotTables need data laid out as a simple table: one header row, one row per record, no blank rows or columns, and no merged cells.

ABCD
1DateRegionRepAmount
203-06-2024NorthAsha1200
305-06-2024SouthLeo800
411-06-2024NorthMei450
514-06-2024EastAsha2300
618-06-2024SouthRaj650
702-07-2024NorthAsha950
809-07-2024EastLeo1600
915-07-2024SouthRaj1100

Creating a PivotTable

  1. Click anywhere in the data.
  2. Choose Insert → PivotTable, and accept the suggested range and a new worksheet.
  3. In the PivotTable Fields pane, tick or drag fields into the four areas:
AreaDoes
Rowsone row in the pivot for each value: each region, each rep
Columnsone column for each value
Valuesthe numbers to summarise: Sum of Amount, Count of Rep...
Filtersa drop-down that limits the whole pivot to certain records

Total by region

Drag Region to Rows and Amount to Values:

RegionSum of Amount
East3900
North2600
South2550
Grand Total9050

Eight rows became a three-line summary. With eighty thousand rows, it would be just as quick.

Two dimensions

Now drag Date to Columns. Excel groups dates by month automatically (right-click a date and choose Group to pick days, months, quarters or years):

RegionJunJulGrand Total
East230016003900
North16509502600
South145011002550
Grand Total540036509050

Changing the calculation

Click the field in Values and choose Value Field Settings to summarise differently:

Summarise byGives, per rep
Sumtotal sales: Asha 4450
Countnumber of sales: Asha 3, Leo 2, Mei 1, Raj 2
Averageaverage sale: Asha 1483.33, Leo 1200, Mei 450, Raj 875
Max, Minthe largest or smallest sale

On the Show Values As tab, % of Grand Total turns totals into shares: East 43.1%, North 28.7%, South 28.2%.

Filtering and slicers

  • Drag Rep to Filters, then pick a rep from the drop-down above the pivot to see only their figures.
  • Or use PivotTable Analyze → Insert Slicer for clickable filter buttons, which are friendlier for anyone reading the report.

Keeping it up to date

A PivotTable doesn't recalculate on its own when the data changes. Right-click it and choose Refresh, or use Data → Refresh All. If you added rows beyond the original range, and the data isn't a Table, use Change Data Source to include them.

Charts from a pivot

With the pivot selected, PivotTable Analyze → PivotChart draws a chart that follows the pivot: filter or rearrange the pivot, and the chart changes too.

Finished this lesson?Mark it complete to earn +20 XP and move your progress on.