A pivot table summarises a long list of rows into a compact grid: total sales by region and product, average score by class and subject, number of tickets by status and week. Excel and Google Sheets have pivot builders, but you do not need either to make one. This guide explains what a pivot table actually computes, how to build one in the browser with the Excel Calculator, the equivalent SQL, and how to read the result without being misled.

What a pivot table does

Every pivot table answers the same kind of question: for each combination of these categories, what is this summary of that number? It has four parts:

  • Rows: the category listed down the left (for example region).
  • Columns: an optional second category spread across the top (product).
  • Values: the numeric column being summarised (revenue).
  • Calculation: how the values in each cell are combined — sum, average, count, minimum, maximum, median or count of unique values.

Behind the scenes, the tool sorts every row into a bucket for its row-and-column combination, then applies the calculation to each bucket. Grand totals apply the same calculation to whole rows, whole columns and the entire table.

Build one in the browser

  1. Open the Excel Calculator and upload your .xlsx or CSV file. Pick the sheet if there are several.
  2. Choose the Pivot table tab.
  3. Set Rows to your main category, and optionally Columns to a second category with a manageable number of values (up to a few dozen).
  4. Choose the Values column and the Calculation.
  5. Download the result as an Excel workbook or CSV, or copy the SQL that produced it.

The file never leaves your browser, which makes this a safe way to summarise payroll, student marks or customer lists on a computer without Office.

The same thing in SQL

A pivot with only rows is a plain GROUP BY:

SELECT region, SUM(revenue) AS revenue
FROM data
GROUP BY region
ORDER BY region;

Spreading a second category across columns uses conditional aggregation — one CASE expression per column:

SELECT region,
       SUM(CASE WHEN product = 'Laptop' THEN revenue END) AS laptop,
       SUM(CASE WHEN product = 'Phone'  THEN revenue END) AS phone,
       SUM(CASE WHEN product = 'Tablet' THEN revenue END) AS tablet,
       SUM(revenue) AS total
FROM data
GROUP BY region;

This is exactly the SQL the Excel Calculator generates (use “Copy SQL” to see it), so you can paste it into SQL Query on CSV or a real database and extend it — add a WHERE clause for a date range, for example.

Choosing the right calculation

CalculationUse it forWatch out for
SumMoney, quantities, hoursNever sum prices, rates or percentages
CountHow many rows (orders, tickets, students)Counts rows, not unique customers
Count uniqueHow many different customers or productsUnique counts do not add up across cells
AveragePrices, scores, durationsSmall groups give unstable averages
MedianTypical value when data is skewedMedians do not add or average across cells
Min / MaxEarliest, latest, extremesOne bad value decides the result

Reading a pivot table honestly

  • Check group sizes. An average of 4.9 from five ratings is not comparable with 4.6 from five hundred. Build a count pivot alongside any average pivot.
  • The grand total of averages is not the average of averages. The grand-total row recalculates over all rows, which weights large groups more. That is usually what you want, but it surprises people.
  • Blank cells mean no rows, not zero. For sums, treat them as zero; for averages, they mean “unknown”.
  • Beware of mixed categories. “North” and “north ” become separate rows. Clean spelling and spaces first — the CSV Analyzer flags them.
  • Look for Simpson’s paradox. A trend that holds in every group can reverse when groups are combined, if group sizes differ. When a total surprises you, check the breakdown.

From pivot to chart

A pivot table with a category down the side and a few columns across is already a grouped bar chart in disguise. Download it as CSV and load it into CSV to Chart, or build the chart directly from the raw rows — see How to Choose the Right Chart and How to Make a Graph from Excel Data for layout tips.