# Pivot table

> A spreadsheet tool that summarizes a long list into totals by category, in a few clicks.

- Level: Basic
- Topics: Data
- URL: https://tidbit.legios.com.ar/pivot-table/
- In Spanish: [Tabla dinámica](https://tidbit.legios.com.ar/es/pivot-table/)

A **pivot table** takes a long list of records, like ten thousand rows of sales with date, region, product and amount, and summarizes it into a compact grid. You choose what goes in the rows (say, regions), what goes in the columns (months) and what to calculate in each cell (the sum of the amount). The result is a small table of totals that would take hours to build by hand.

The "pivot" part is that you can rearrange it instantly: drag product into the rows instead of region, switch the sum to an average or a count, add a filter for one year. Each change recalculates from the original data, which stays untouched. That makes it a great tool for exploring: you ask a question, look, and ask the next one.

Pivot tables are built into Excel, Google Sheets and LibreOffice, and they are often the first serious data analysis tool people learn. Under the hood they do the same thing as a `GROUP BY` query in SQL. When the data grows past what a spreadsheet handles comfortably, the same idea moves to databases and BI tools.

## An analogy

Like sorting a big bag of receipts into piles by store and by month, then writing the total on top of each pile, except the computer re-sorts the whole bag any way you want in a second.

## Keep in mind

- Summarizes many rows into totals grouped by categories.
- You pick rows, columns, the calculation and filters, and can rearrange them freely.
- The original data is never changed.
- It is the spreadsheet version of SQL's GROUP BY.

## Go deeper

- [Create and use pivot tables (Google Sheets help)](https://support.google.com/docs/answer/1272900)
- [Pivot table on Wikipedia](https://en.wikipedia.org/wiki/Pivot_table)

## Related terms

- [Regions and Availability Zones](https://tidbit.legios.com.ar/regions-and-availability-zones/): Where AWS physically lives: cities worldwide, each split into separate data centers.
- [Spreadsheet vs database](https://tidbit.legios.com.ar/spreadsheet-vs-database/): Why a company that runs on Excel eventually needs a real database.
- [SQL](https://tidbit.legios.com.ar/sql/): The language you use to ask a database questions.
- [Database](https://tidbit.legios.com.ar/database/): An organized store of data that programs can search and update safely.
- [Business intelligence](https://tidbit.legios.com.ar/business-intelligence/): Turning a company's data into reports and dashboards people use to decide.
