BUS 120 · Spreadsheets and Business Data

Pivot Tables

Turn a long list of transactions into a clear summary with pivot tables, then check that the totals still agree.

Key takeaways

  • A pivot table groups the rows of a list and calculates a total, count or average for each group.
  • You build it by placing fields into four areas: rows, columns, values and filters.
  • The source list must be clean, with one header row and one record per row.
  • A pivot table does not update by itself when the data changes, so you must refresh it.
  • Always check that the grand total matches a total taken directly from the source list.

Sofia sells tacos from an invented food truck called Corner Comet. After a busy month she has a list with hundreds of sales, one per row: date, location, item, quantity and amount. Her business partner asks a simple question: "Which location makes the most money?"

Sofia could filter to the first location and write down the total. Then the second. Then the third. Then her partner would ask, "And by item?" and she would start over.

A pivot table answers both questions in seconds. It is a summary that the spreadsheet builds from your list, and that you can rearrange by dragging field names around. You do not write a single formula. You do need to understand what it is doing, or it will summarize your confusion just as quickly.

Grouping: the idea underneath

Imagine sorting a pile of receipts into shoeboxes, one box per location. Then you add up each box and write the sum on the lid. That is a pivot table. The sorting is grouping, and the adding is aggregating, which means boiling many values down to one.

The same receipts can be re-boxed by item, by day or by payment type. The receipts never change. Only the boxes do.

A pivot table reads from a source, your original list. It copies a snapshot of that data into memory, called a pivot cache, and builds the summary from the snapshot.

From receipts to summary
1 Source list One row for every sale. 2 Group Rows that share a location go together. 3 Aggregate Add the amounts in each group. 4 Display One line per location, plus a grand total. Source list One row for every sale. 1 Group Rows that share a location go together. 2 Aggregate Add the amounts in each group. 3 Display One line per location, plus a grand total. 4

Start with a question

It is tempting to drag fields around until something interesting appears. Exploring is fine, but you will get further if you write the question first. "Which location sells the most?" names a group (location) and a figure to add (amount). "How many burrito sales happened at each location?" names a group, a filter (burritos) and a count.

A simple pattern helps: "I want the ___ of ___ for each ___." The first blank is the calculation, such as sum or count. The second is the number field. The third goes in rows. Anything that begins with "only" usually belongs in the filters area.

If your question does not fit the pattern, check whether your list even holds the needed fact. A pivot table cannot tell Sofia which sales were paid by card if nobody recorded the payment type.

The source data comes first

Before you insert anything, check the list against the rules in tables, sorting and filtering.

  • Every column has a header.
  • There are no blank rows or subtotal rows inside the data.
  • Amounts are numbers, not text.
  • Dates are real dates.
  • Names are spelled one way. "Park" and "park " may become two groups.

It also helps to make the source an Excel table. When rows are added, the table grows, and a refresh picks them up.

The four areas

In Excel, click inside your data, choose Insert, then PivotTable, and pick a new worksheet. A panel lists your field names and four empty areas. Other programs have similar panels with slightly different labels.

Area What it does Sofia's choice
Rows One line for each distinct value Location
Columns One column for each distinct value Item
Values The number to calculate Amount
Filters Limits the whole report Month

Drag Location to Rows and Amount to Values, and you have a total by location. Drag Item to Columns, and you have a grid that shows every combination.

The four areas of a pivot table
Rows Groups listed down the side. Columns Groups listed across the top. Values The figure summed, counted or averaged. Filters Narrows what the whole report includes. Rows Groups listed down the side. Columns Groups listed across the top. Values The figure summed, counted or averaged. Filters Narrows what the whole report includes.

A worked example: Corner Comet's sales

To keep the arithmetic visible, here is a tiny slice of Sofia's list. A real one would be much longer.

Row Location Item Qty Amount
1 Park Taco 10 40
2 Campus Taco 15 60
3 Park Burrito 5 45
4 Market Taco 20 80
5 Campus Burrito 10 90
6 Park Taco 5 20
7 Market Burrito 5 45
8 Campus Taco 5 20

The source total is 40 + 60 + 45 + 80 + 90 + 20 + 45 + 20 = 400.

With Location in Rows, Item in Columns and Amount in Values, the pivot table shows:

Location Burrito Taco Grand Total
Campus 90 80 170
Market 45 80 125
Park 45 60 105
Grand Total 180 220 400

Check one cell by hand. Park tacos come from rows 1 and 6: 40 + 20 = 60. Campus tacos come from rows 2 and 8: 60 + 20 = 80. The grand total is 400, matching the source.

Now Sofia can answer her partner. Campus brings in the most, with 170 out of 400, which is 42.5%.

Count and average

Change the value setting from Sum to Count, and the same layout shows the number of sales lines. Campus has 3 lines (rows 2, 5 and 8). Change it to Average and Campus shows 170 ÷ 3, about 56.67 per line.

Put Qty in Values too. Campus sold 15 + 10 + 5 = 30 units. So revenue per unit at Campus is 170 ÷ 30, about 5.67. Park sold 10 + 5 + 5 = 20 units for 105, or 5.25 each. The mix matters: burritos cost more per unit than tacos.

Corner Comet sales by location
Campus $170 Market $125 Park $105 Campus $170 Market $125 Park $105

The three locations add to the grand total of $400. Hypothetical example: the numbers are made up to show the method, not a quote or an average.

Swap the layout and look again

Now move Item to Rows and Location to Columns. The grid turns on its side, but every number stays the same. Burritos still total 180 and tacos 220. Rearranging a pivot table is called pivoting, and it is where the name comes from.

Next, remove Location altogether. You get just two lines, Burrito 180 and Taco 220. Tacos bring in more money, 55% of the total. Compare units too. Tacos sold 10 + 15 + 20 + 5 + 5 = 55 units, while burritos sold 5 + 10 + 5 = 20. So each taco brings in 220 ÷ 55 = 4 dollars and each burrito 180 ÷ 20 = 9 dollars.

Which item is "better"? The pivot table cannot say. Revenue is not profit. Sofia would need the cost of ingredients and the time each item takes. The idea of what each unit leaves behind after its own costs is called contribution margin.

Shaping the report

Once the basic layout works, a few settings make it far more useful.

Show values as a percentage. You can display each figure as a share of the grand total. Campus shows 42.5%, Market 31.25% and Park 26.25%. These add to 100%.

Group dates. Put a date field in Rows, and many programs can bundle days into months, quarters or years. This turns a long calendar into a trend you can read.

Sort the summary. Sort locations by total, largest first, so the answer sits on top.

Drill down. In Excel, double-click a number, and a new sheet appears listing the source rows behind it. It is a fast way to ask "what is inside this figure?"

Slice it. Slicers add buttons for choosing a location or month, and they show what is currently selected.

Calculated fields let a pivot table compute new values. Be careful with ratios. A calculated field generally works on the sums of its inputs, not row by row. For a ratio such as price per unit, total revenue divided by total units is usually what you want. Test it against a hand calculation.

Reading a pivot table honestly

A summary can mislead without containing a single wrong number. Campus leads in total sales, but suppose Sofia parks there twelve days a month and at Market only four. Per visit, Market might be the stronger spot. Totals reward whatever had the most chances.

Ask what the fair comparison is. Sales per day, per hour or per unit may answer the real question better than a plain sum. Add the needed field to your source, such as one row per visit or a column for hours, and the pivot table can group it. Then divide total sales by total hours for each location.

Also watch for small groups. An average built on one sale tells you very little. Show the count beside the average so readers can judge how much weight it deserves.

The common mistake: trusting a stale or partial pivot

Sofia adds a $75 sale on Friday and opens her pivot table. It still says 400. Nothing is broken. A pivot table shows its snapshot until you refresh it. Right-click inside it and choose Refresh, or use the Refresh button on the ribbon.

After refreshing, the total should read 475. If it still says 400, the new row is probably outside the source range. A pivot table built on a fixed range such as A1:E9 will not see row 10. Building from a table avoids this.

Other warning signs:

  • A group called (blank) means some rows are missing that field.
  • Two nearly identical groups mean inconsistent spelling or stray spaces.
  • A value area that shows Count when you expected Sum often means the column contains text or blank cells.
  • A filter left on can silently exclude whole months.

The cure for all of these is the same. Compare the grand total with =SUM on the source column. If they differ, find out why before you share anything.

Be careful with matching totals, too. A grand total can agree while the groups are wrong, for instance when a sale is tagged with the wrong location. Spot-check a few source rows against receipts or records from the sales system.

A tidy routine before sharing takes about a minute: refresh, check the filters, compare the grand total, look for blank or duplicate groups and add a title that states the period covered.

When a formula is the better tool

Pivot tables are great for exploring. Sometimes you want a fixed layout that updates instantly and feeds other calculations. Then SUMIFS from formulas and essential functions may serve better. For Campus tacos:

=SUMIFS(E2:E9, B2:B9, "Campus", C2:C9, "Taco")   → 80

Many people use both. They explore with a pivot table, then build the monthly report with formulas, and use each to check the other. When two independent methods agree on 80, you can relax a little.

Next, charts for financial data show how to turn a summary into a picture people grasp at a glance.

Words to know

Pivot table a summary built from a list that groups records and calculates figures for each group.

Source data the original list that a summary is built from.

Aggregate to combine many values into one, such as a sum, count or average.

Grand total the figure covering every record the pivot table includes.

Refresh to rebuild the summary from the current source data.

Drill down to open a summary figure and see the records behind it.

Check yourself

  1. What are the four areas of a pivot table?
  2. In the example, what are total burrito sales, and which rows make them up?
  3. What share of the 400 in sales came from Market?
  4. How many sales lines and what average amount does Park have?
  5. You add data, refresh and the total does not change. What is a likely cause?
  6. Why compare the grand total with a SUM on the source column?
Show the answers
  1. Rows, columns, values and filters.
  2. Rows 3, 5 and 7 give 45 + 90 + 45 = 180.
  3. Market is 125 ÷ 400 = 31.25%.
  4. Park has rows 1, 3 and 6, so 3 lines averaging 105 ÷ 3 = 35.
  5. The new row is outside the pivot table's fixed source range.
  6. It catches stale snapshots, active filters and missing rows before anyone relies on the summary.

A free self-study program written for 4Accounting with AI writing tools and not reviewed line by line by a person. It is not an accredited degree and awards no credit. Check anything you rely on against a textbook or primary source. Report an error.

In this unit: Analysis

  1. Pivot TablesTurn a long list of transactions into a clear summary with pivot tables, then check that the totals still agree.10 min
  2. Charts for Financial DataChoose the right chart for a financial question, build it from clean data and avoid pictures that mislead.11 min
  3. Financial Functions for Loans and InvestmentsUse PMT, FV, PV, RATE, NPV and IRR correctly, with matching periods, sensible signs and a check on every answer.11 min
  4. Designing a Workbook Others Can TrustLay out a workbook with separate inputs, calculations and outputs so that another person can follow and check it.10 min
  5. Error Checking and Spreadsheet ControlsFind spreadsheet mistakes with control totals, check formulas and review habits before they reach a report.10 min
  6. What-If Analysis and ScenariosTest how results change when assumptions change, using input cells, data tables, Goal Seek and best, base and worst cases.10 min

In the news