1. Courses
  2. Data
  3. Data Analysis with Excel, Python & AI
  4. Stop 3

35 minBeginner

Pivot tables and summaries

A clean table of 24,000 rows answers nothing until you summarise it. This lesson teaches you to build pivot tables and SUMIFS summaries, to pick the right summary (sum, count or average), to compare periods fairly, and to find which stores and categories make up a change. In the course story, this is where East city's drop stops being one number and becomes 9 stores and two aisles.

By the end you can

  • Build a pivot table from rows, columns, values and filters, and say what each cell adds up
  • Choose sum, count or average, and compute averages as a ratio of sums
  • Show % of total, week-over-week change and change against the same weeks last year
  • Write the same summary with SUMIFS when you need a fixed report layout
  • Split a total change into the contribution of each store and category, and find where it is concentrated

The everyday picture

A shopkeeper keeps every receipt in a shoebox. At the end of the month she wants to know what sold. She lays envelopes on the table in a grid: one row of envelopes per product group, one column per week. She drops each receipt line into its envelope, then adds up each envelope and writes the total on the front.

Now she puts last year's box next to this year's and does the same. Most envelopes weigh about the same as last year. Two are much lighter: fruit and bread. She doesn't need to read all 1,000 receipts again. She knows where to look next.

A pivot table is that envelope grid, built in a second. You choose what goes in the rows, what goes in the columns and what to add up, and the spreadsheet sorts every row of your data into exactly one envelope.

How a pivot table works

A does three things, in this order. First it filters: rows that don't match the filter are left out. Then it groups: every remaining row goes into exactly one cell, chosen by its value in the row field and the column field. Finally it summarises: for each cell, it adds up (or counts, or averages) the value field over the rows in that cell. The grand totals are the same summary over a whole row, a whole column or everything.

You set this up in four areas. Excel calls them Filters, Columns, Rows and Values; Google Sheets has Rows, Columns, Values and Filters in its pivot table editor. In Excel, click any cell of your data and choose Insert, then PivotTable. In Google Sheets, choose Insert, then Pivot table. Then drag field names into the areas.

Source table date store category sales 2026-10-05 E-17 Fresh produce 1,840 2026-10-05 E-17 Bakery 910 24,000 more rows drag 4 fields Filters city: East Columns year Rows category Values sum(sales) sum each cell category 2025 2026 Fresh produce 820 760 Bakery 400 368 Other 3 groups 4,070 4,002 Total 5,290 5,130
The pivot filters to East city, puts each row in the cell for its category and year, and sums the sales in each cell. The source is already limited to the same 4 weeks in both years; values are thousands of dollars a week.

Three habits keep pivots honest. Start from a clean, tidy table with one header row and no subtotal rows, as you built in Cleaning data in a spreadsheet. Know the of the source: here one row is one store, one day, one category, so 54 stores times 56 days times 8 categories gives 24,192 rows. And remember that an Excel pivot does not update when the data changes: you refresh it (right-click the pivot and choose Refresh). If your data is an Excel Table (Ctrl+T), new rows are included when you refresh. Google Sheets pivot tables update on their own when the source cells change.

Quick check

You want one row per store and one column per week, showing that store's sales in that week. Where do the fields go?

Loading the rest of the lesson…