What a pivot table does and why you'd use one
A pivot table is a tool that takes raw data — rows and columns of numbers, dates, and categories — and reorganizes it to show you patterns and totals. Instead of scrolling through thousands of rows to find what you need, a pivot table groups your data by the fields you choose and calculates sums, counts, or averages automatically.
The most common reason to build one is to answer a question your raw data won't answer directly. If you have a spreadsheet of sales transactions with columns for date, product, region, and amount, a pivot table can show you total sales by region, or sales by product by month, without writing formulas or manually sorting. You rearrange the same data into a new shape.
Both Excel and Google Sheets have pivot table features built in. The steps differ slightly between them, but the logic is the same: you select your data, tell the tool which fields to group by and which to calculate, and it builds the table for you.
Key Takeaways
- A pivot table reorganizes raw data to show totals, counts, or averages grouped by the fields you choose, without changing your original data.
- Your data must have headers in the first row, with no blank rows or columns mixed into the data range you select.
- In Excel, use the Data menu to insert a pivot table; in Google Sheets, use the Data menu and select Pivot Table.
- Drag fields into Rows, Columns, and Values areas to control how the pivot table groups and calculates your data.
- You can filter, sort, and refresh a pivot table after you build it, and it updates automatically if you change the source data.
Preparing your data before you start
Pivot tables work best when your data is organized in a specific way. The first row must contain headers — the names of each column, like "Date", "Product", "Region", "Sales Amount". Every row below that should contain actual data with no blank rows in the middle. If your data has blank cells scattered throughout, the pivot table may not include those rows in its calculations.
Check that each column contains only one type of information. A column labeled "Date" should have dates, not a mix of dates and text notes. A column labeled "Amount" should have numbers, not text like "approx. $500". If you have messy data with mixed types, clean it up first — split columns if needed, remove extra spaces, and make sure numbers are stored as numbers, not text.
Select the entire data range including headers before you start. In Excel, you can click any cell in the data and the tool will usually find the full range automatically. In Google Sheets, you should select the range yourself to be sure. Do not include extra blank rows or columns outside your data.
Building a pivot table in Excel
Open your spreadsheet and click any cell in your data range. Go to the Data menu at the top and select Pivot Table (in Excel 2016 and later, this appears as Pivot Table under the Insert menu, depending on your version). A dialog box will appear asking where you want the pivot table to go — you can place it in a new sheet or in the same sheet below your data.
Excel will show you a Pivot Table Fields panel on the right side of the screen. This panel lists all the column headers from your data. Below that are four areas: Filters, Columns, Rows, and Values. Drag fields from the list into these areas to build your table. For example, if you want to see sales totals by region, drag "Region" into the Rows area and "Sales Amount" into the Values area. Excel will automatically sum the amounts.
The Values area is where calculations happen. By default, Excel sums numbers and counts text. If you need a different calculation — an average instead of a sum, for instance — double-click the field in the Values area and choose a different function from the menu. Once you have arranged your fields, click outside the panel or press Enter, and the pivot table appears on your screen.
Building a pivot table in Google Sheets
Click any cell in your data range. Go to the Data menu and select Pivot Table. A new sheet will open with a pivot table editor on the right side. Google Sheets will suggest a data range; check that it includes all your data and no extra rows or columns, then click Create.
The pivot table editor shows a list of fields from your data on the left. On the right are four sections: Rows, Columns, Values, and Filters. Drag fields into these sections to build your table. If you want to see sales by region and by month, drag "Region" into Rows, "Month" into Columns, and "Sales Amount" into Values. Google Sheets will sum the amounts by default.
To change how a field is calculated, click the field name in the Values section and select a different function — sum, count, average, minimum, maximum, and others are available. The pivot table updates as you drag fields and change settings. Unlike Excel, Google Sheets creates the pivot table on a new sheet automatically, so your original data stays untouched on the first sheet.
Organizing rows, columns, and values
The layout of your pivot table depends on which fields you put where. Rows become the left side of your table — each unique value in that field gets its own row. Columns become the top headers — each unique value becomes a column. Values are the numbers in the cells, calculated from your data.
If you drag "Product" into Rows and "Region" into Columns, you get a table where each product is a row and each region is a column, with sales totals in the cells. If you drag both "Product" and "Region" into Rows, you get a nested table where products are grouped by region, or region by product, depending on the order you dragged them.
The Filters area lets you narrow the pivot table to show only certain values. If you drag "Year" into Filters, a dropdown appears above the table so you can show only 2023 data, or only 2024, without rebuilding the whole table. This is useful when your data spans multiple years or categories and you want to focus on one at a time.
Filtering and sorting your pivot table
After you build a pivot table, you can filter and sort it without rebuilding. In both Excel and Google Sheets, small dropdown arrows appear in the row and column headers. Click an arrow to open a menu where you can uncheck values you do not want to see, or sort from smallest to largest, largest to smallest, or alphabetically.
If you added a field to the Filters area, a dropdown menu appears above the table. Use it to show only the data you want. For example, if "Year" is in Filters, you can select 2024 to see only that year's data, then switch back to 2023 without rebuilding the table.
In Excel, right-click a cell in the pivot table and select Sort to sort by that column. In Google Sheets, click the column header dropdown and choose your sort order. Both tools let you sort by the calculated values (like total sales) or by the row labels themselves (like alphabetically by product name).
Refreshing and updating your pivot table
If you change numbers in your original data, the pivot table does not update automatically in Excel — you have to refresh it. Right-click anywhere in the pivot table and select Refresh, or go to the Data menu and choose Refresh All. In Google Sheets, the pivot table updates automatically when you change the source data, so you do not have to do anything.
If you add new rows to your original data after you build the pivot table, Excel may not include them in the next refresh. To make sure new data is included, you can edit the pivot table's data range. Right-click the pivot table, select Pivot Table Options, and update the range to include the new rows.
In Google Sheets, if you add new data to your source sheet, the pivot table will include it automatically on the next refresh. If it does not, click the refresh icon in the pivot table editor on the right side of the screen.
Common mistakes and how to avoid them
The most common mistake is including blank rows or columns in your data range. If row 50 is blank and your data continues in row 51, the pivot table may stop at row 49 and miss everything below. Clean your data first: delete blank rows, remove extra spaces from cell values, and make sure headers are in the first row with no blank rows above them.
Another mistake is putting text in a column that should contain numbers. If a "Sales Amount" column has entries like "approx. $500" or "500 dollars", the pivot table will treat it as text and count it instead of summing it. Go back to your data, remove the text, and keep only the numbers. Use a separate column for notes if you need them.
A third mistake is dragging too many fields into the Rows or Columns area, which creates a table so wide or tall that it is hard to read. Start simple: one or two fields in Rows, one in Columns, and one in Values. Once you see the pattern, you can add more fields if needed.
Frequently Asked Questions
Can I edit the numbers in a pivot table directly?
No. A pivot table is a summary of your source data, not an independent spreadsheet. If you need to change a number, go back to your original data and edit it there, then refresh the pivot table. Trying to edit a pivot table cell directly will not work or will cause an error.
What if my data has duplicate headers or headers in the wrong place?
The pivot table tool expects headers in the first row only. If you have headers repeated in the middle of your data, or if your actual headers are in row 2 instead of row 1, the pivot table will treat them as data and include them in the calculations. Move your headers to row 1, delete any duplicate header rows, and try again.
Can I create a pivot table from data in multiple sheets?
In Excel, you can use the Data Model feature to combine data from multiple sheets, but it is more complex than a basic pivot table. In Google Sheets, you cannot build a pivot table from multiple sheets directly — you would need to combine the data into one sheet first. For most purposes, copying all your data into a single sheet is the simplest approach.
How do I move or copy a pivot table?
In Excel, you can cut and paste a pivot table like any other object, but it is usually safer to rebuild it in the new location. In Google Sheets, the pivot table lives on its own sheet, so you can rename or move the sheet, but you cannot move the pivot table itself to a different sheet. If you need it elsewhere, create a new pivot table from the same source data.
What calculations can I use in the Values area?
Both Excel and Google Sheets offer sum, count, average, minimum, maximum, and standard deviation. Excel also includes product, count of numbers only, and variance. Google Sheets includes median and percentile. The calculation you choose depends on your question — use sum for totals, average for typical values, count to see how many transactions or records you have.