Sub topic 4
Inserting a PivotTable
This chapter covers how to create a PivotTable from a range or an Excel Table, where to place it, and what Excel gives you when the command finishes. It assumes you can move around workbooks, worksheets, cells and ranges, and that you have a flat dataset with one header row and one record per row. Preparing that data and converting it to an Excel Table are covered in earlier chapters.
What the Insert command actually creates
Inserting a PivotTable does not produce a finished report. It creates an empty PivotTable placeholder and a PivotTable Fields pane, plus a cache of your source data stored inside the workbook. You then build the report by dragging fields into areas, which is the topic of the next chapter.
Two parts are worth knowing about from the start:
- The PivotTable is a separate object from the source data. It reads from the source but does not change it.
- The PivotTable reads from a pivot cache, which is a copy of the source data held in the workbook. The PivotTable shows the cache, so changes to the source do not appear until you refresh.
The sample data used here is the same small dataset from the earlier chapters.
Date,Region,Product,Units,Sales
2025-01-05,East,Widget,10,250
2025-01-12,West,Gadget,4,180
2025-02-03,East,Gadget,7,315
2025-02-14,West,Widget,12,300
2025-03-09,East,Widget,5,125Step by step: insert from a range or Table
- Click any single cell inside the data. Do not select the whole range by hand unless you need to. Excel detects the surrounding block of data on its own, and it stops at blank rows and blank columns.
- On the Insert tab, choose PivotTable, then From Table/Range. In older versions the button is simply PivotTable.
- In the PivotTable from table or range dialog, check the Table/Range box. It should show your Table name, such as
Table1, or a range address such asSheet1!$A$1:$E$6. - Under Choose where you want the PivotTable to be placed, pick New Worksheet or Existing Worksheet.
- Click OK.
If you started from an Excel Table, the dialog shows the Table name instead of a fixed address. This is the main reason to convert first. A Table name grows when you add rows, and a fixed address does not.
You can also use Insert > Recommended PivotTables. Excel previews a few ready-made layouts based on your data. This is useful for exploring, but it picks the layout for you, so the later chapters on field placement matter more for controlled reports.
Choosing where to place the PivotTable
| Placement | When to use it | Trade-off |
|---|---|---|
| New Worksheet | Default choice. Keeps the report away from the data. | Adds a sheet per PivotTable. |
| Existing Worksheet | Dashboards where several PivotTables and charts share a sheet. | You must pick a cell with enough empty room. |
With Existing Worksheet, the Location cell is the top-left corner of the PivotTable area. A PivotTable expands downward and to the right as you add fields, and it cannot overwrite other cells. If it would run into other content, Excel shows the error "A PivotTable report cannot overlap another PivotTable report". Leave generous space, or give each PivotTable its own sheet.
Never place a PivotTable in the same cells as the source data. A PivotTable that grows will collide with the data, and you may block new records from being added.
Checking what Excel selected
The dialog's range guess is wrong more often than people expect. Check it before clicking OK, especially in these cases:
- A blank row inside the data. Excel selects only the block above the blank row, so later records are silently left out.
- A title or note above the headers. If the title sits directly against the header row, Excel may treat it as part of the data.
- Total rows at the bottom. A row labelled Total is included as a record and double-counts your sums.
- A blank header cell. Creation fails with the message "The PivotTable field name is not valid".
The last error is easy to fix. Every column needs a unique, non-empty header, so add or correct the missing header and insert again.
Using an external or data model source
The same dialog offers two other options:
- Use an external data source connects to a database or another workbook. You choose a connection and the PivotTable reads from it.
- Add this data to the Data Model stores the data in the workbook's data model. This allows relationships between tables and the Distinct Count summary, at the cost of a larger file and some features, such as grouping behaviour and calculated fields, working differently.
For a single flat table, leave both unchecked. The rest of this tutorial assumes the standard pivot cache.
Several PivotTables from one source
When you insert a second PivotTable from the same range, Excel usually reuses the existing pivot cache. This keeps the file small, and Refresh updates both PivotTables together. A side effect is that they share some settings. For example, grouping a date field in one PivotTable also groups it in the other.
If you need independent PivotTables, for example with different groupings, you can create a separate cache. Copying the data to another sheet or building the second PivotTable from a different Table forces that. Each cache adds to the file size.
What you see after clicking OK
You see a grey block on the worksheet that reads "PivotTable1" with the instruction to choose fields from the list. The ribbon gains two contextual tabs, PivotTable Analyze and Design. They appear only while a cell inside the PivotTable is selected, which causes a common confusion. If the tabs and the Fields pane vanish, click a cell inside the PivotTable and they return. If the pane stays hidden, use PivotTable Analyze > Field List.
The pane lists every column header from the source as a field. Nothing is calculated yet. In the next chapter you will use this pane, with a first layout such as this one.
Rows: Region
Columns: Product
Values: Sum of SalesCommon errors when inserting
| Message or symptom | Cause | Fix |
|---|---|---|
| "The PivotTable field name is not valid" | A header cell is blank | Add a unique header to every column |
| "Reference isn't valid" | The Table or range name does not exist, or the typed address is wrong | Re-select the data or correct the name |
| "A PivotTable report cannot overlap another PivotTable report" | The chosen location is too close to another PivotTable | Choose a cell with more empty room or a new worksheet |
| Some records are missing | A blank row split the data | Remove the blank row, then change the data source |
| PivotTable button is greyed out | The sheet is protected, or you are in cell edit mode | Press Esc, or unprotect the sheet |
Keyboard and naming habits
Give each PivotTable a meaningful name early. Select a cell in it, open PivotTable Analyze, and edit the PivotTable Name box, for example pvtSalesByRegion. Default names such as PivotTable1 become hard to tell apart once a workbook holds several, and macros and some formulas refer to PivotTables by name.
You can also rename the worksheet to match. Name the sheet after the question the report answers, not after the technique.
Exercise
You select a cell in a dataset of 500 rows and insert a PivotTable. Later you notice the PivotTable totals cover only the first 200 rows. Row 201 is completely blank. What happened, and how do you fix it?
Show answer
Excel detected the contiguous block of data and stopped at the blank row, so the pivot cache contains only rows 1 to 200. Delete the blank row (or fill it in), preferably convert the data to an Excel Table, then use PivotTable Analyze > Change Data Source to select the full range or Table, and refresh.
Exercise
You place a new PivotTable on an existing worksheet at cell D2, and Excel reports that it cannot overlap another PivotTable. What are two ways to resolve this?
Show answer
Choose a location with more empty room, such as a cell further right or lower down, or place the PivotTable on a New Worksheet. Either option gives the PivotTable space to grow without colliding with the other one.