Pivot table

On this page 7

A pivot table is an interactive summary that groups, aggregates and cross-tabulates rows of tabular data by the fields a user chooses, without altering the source records. Among office applications it is the standard self-service analysis feature of spreadsheet software such as Microsoft Excel, Google Sheets and LibreOffice Calc, where it turns thousands of transactions into a compact report in seconds.

The name describes its defining behavior: a user can pivot the layout by dragging a field from rows to columns or into a filter, and the program recalculates every total for the new arrangement. This makes the pivot table the bridge between raw lists and decision-ready reports in everyday software use.

How a pivot table summarizes data

A pivot table works by building a cache of the source range, classifying each column as a field, and then computing an aggregate value for every combination of the items placed in its layout areas. The source must be a flat, list-shaped table: one header row, one record per row, and one kind of value per column.

The user assigns fields to four layout areas, and each area plays a distinct role in the final grid. The table below shows what each area does.

AreaRoleTypical field
RowsCreates one row label per unique itemProduct, region, customer
ColumnsSpreads unique items across the topYear, quarter, channel
ValuesHolds the aggregated numbersRevenue, quantity, cost
FiltersRestricts the whole report to selected itemsCountry, sales team
The four layout areas of a pivot table

Because the engine reads from the cache rather than the live cells, a pivot table does not update automatically in most desktop spreadsheets. After the source changes, the user must refresh the pivot table, or configure a refresh on file open. Google Sheets is an exception, since it recalculates pivot tables as part of normal sheet recalculation.

Aggregation functions and calculated values

Every value field uses an aggregation function that collapses many source rows into one number per cell. Sum is the default for numeric columns and Count is the default for text columns, a rule that often surprises users when a numeric column contains a stray text entry.

OptionWhat it returnsTypical use
SumTotal of all matching valuesRevenue by month
CountNumber of matching recordsOrders per customer
AverageArithmetic mean of matching valuesAverage ticket size
Distinct countNumber of unique itemsUnique buyers per region
Percent of totalShare of the grand or column totalMarket share by product
Running totalCumulative value along a fieldYear-to-date sales
Common aggregation and display options

Beyond these options, users can add a calculated field, which applies a formula to aggregated fields, or a calculated item, which combines items within one field. A frequent error is computing a ratio as a calculated field when the correct result requires row-level calculation first: an average of margins is not the same as total margin divided by total revenue.

Grouping adds another layer. Dates can be grouped into months, quarters and years, numbers can be banded into ranges such as 0-99 and 100-199, and selected text items can be combined into custom groups such as a sales territory.

Pivot tables compared with formulas and other tools

A pivot table is one of several ways to summarize data in a spreadsheet, and the right choice depends on how often the layout changes and how much the report must be formatted. Formula-based summaries such as SUMIFS give fixed, fully controllable layouts, while lookup functions such as VLOOKUP retrieve values rather than aggregate them.

MethodStrengthLimitation
Pivot tableFast, flexible regrouping without formulasNeeds refresh and resists custom layouts
SUMIFS and COUNTIFSExact control over cell positionsEvery new dimension needs new formulas
Subtotal featureSimple totals inside a sorted listOne grouping level at a time
Data model pivotJoins related tables, handles millions of rowsRequires defined relationships and measures
BI dashboardShared, governed, scheduled reportsSeparate tool and license
Pivot tables and alternative summarizing methods

In Microsoft Excel, a pivot table can be built on the Data Model, an in-memory columnar engine that relates several tables and supports measures written in DAX. This removes the classic need to flatten data with lookups before pivoting, and it raises the practical row limit far beyond the 1,048,576 rows of a single worksheet.

Preparing source data and building the report

Most pivot table problems originate in the source, so clean, structured input matters more than any setting. Converting the range into a formatted table (an Excel Table or a named range) lets the pivot table expand automatically when new rows are added.

  • Use one header row with unique, descriptive names and no merged cells.
  • Store one data type per column: dates as real dates, numbers as numbers.
  • Avoid blank rows and subtotal rows inside the source list.
  • Keep data in long format, with months as values in one column rather than twelve separate columns.
  • Refresh after every source change and check the grand total against the source.

A practical build follows a fixed order: place the analytical question in words first, then select the value field, then the row dimension, then the column dimension, and only then the filters or slicers. Slicers and timelines are visual filter controls that make a pivot table usable by colleagues who never open the field list.

Common mistakes and limitations

A pivot table is reliable only when its user understands what the cache contains and how each total is defined. The table below lists frequent symptoms, their causes and remedies.

SymptomLikely causeFix
Totals ignore new rowsFixed source rangeUse a formatted table, then refresh
Values show Count instead of SumText or blank cells in a number columnClean the column, change the function
Same item appears twiceTrailing spaces or inconsistent spellingTrim and standardize source values
Dates will not groupDates stored as textConvert the column to real dates
Ratios look wrongAverage of ratios usedDivide totals in a calculated field
Pivot table symptoms, causes and fixes

Other limitations are structural. Formatting may reset on refresh unless preserved explicitly, GETPIVOTDATA references can break when the layout changes, and file portability between applications is imperfect: a pivot table saved in XLSX usually opens in LibreOffice or ONLYOFFICE, but data model features and some slicers may not survive the conversion. Finally, a pivot table cache can contain hidden copies of sensitive data, even when the visible report shows only totals.

Put simply

A pivot table is a way to ask a big list a question and get a short answer. Imagine a shoebox full of receipts. Instead of adding them up by hand, you tell the spreadsheet to sort the receipts into piles by shop and by month and to write the total on each pile.

If you then want the piles arranged by product instead, you simply move one label, and every total is recalculated for you. The original receipts stay untouched. The key idea is fast regrouping: the same data can answer many different questions in seconds.

In practice

A finance analyst at a mid-sized distributor receives a monthly export of about 60,000 invoice lines, each with date, customer, product category, region and net amount. Management wants revenue by region and quarter, plus the share of each product category.

The analyst formats the export as a table, inserts a pivot table, places region in rows, groups the invoice date into quarters in columns and adds net amount as a Sum. A second value field shows the same amount as percent of column total, and a slicer for product category lets managers filter the view themselves.

The first report takes under ten minutes instead of the half day previously spent on SUMIFS formulas. Each month the analyst pastes the new export into the same table and refreshes, and a quick check that the grand total matches the ledger confirms that no rows were lost.