Sub topic 2
Preparing your source data
A pivot table is only as reliable as the range behind it. Most pivot problems, such as missing rows, wrong counts and fields that won't sum, come from the source data and not from the pivot table. This chapter covers the shape your data needs, the mistakes that break it, and a short checklist to run before you build anything.
This chapter assumes you can select ranges, use menus and enter simple formulas in Google Sheets. It also assumes you know that data is stored as records (rows) and fields (columns), and that you understand sum, count and average.
What a pivot table expects
A pivot table reads a flat table. Each row is one record, such as one sale. Each column is one field, such as Region or Revenue. The first row holds the field names. Google Sheets turns those names into the field list in the pivot table editor.
Here is a well-formed source range on a sheet named Sales:
| Date | Region | Rep | Product | Revenue | Units |
|---|---|---|---|---|---|
| 2026-01-04 | West | Ana | Widget | 1200 | 12 |
| 2026-01-09 | East | Ben | Gadget | 800 | 4 |
| 2026-01-15 | West | Cara | Widget | 450 | 5 |
| 2026-02-02 | North | Ana | Gadget | 975 | 5 |
Every row is a complete record. Every column has one header and one kind of value. Nothing else sits inside the table.
Rules for a reliable source range
One header row, with a unique name in every column
Each column needs a header, and each header must be distinct. A blank header makes the pivot table editor refuse the range or produce an unnamed field. Two columns both named Amount are hard to tell apart in the editor. Use specific names such as Revenue and Discount.
Keep headers to a single row. If your sheet has a two-level header, with a group label above each set of columns, merge the two levels into one name per column, for example Q1 Revenue.
One kind of value per column
The pivot table decides how to treat a field from what the column contains. A column that mixes numbers and text gets summarized unpredictably. Common causes:
- Numbers stored as text, which show up left-aligned or with a small leading apostrophe. A sum ignores them and a count includes them.
- Placeholder text such as
n/a,-orTBDinside a numeric column. - Currency symbols or units typed into the cell, such as
$1,200or12 units, when the cell is plain text. - Dates typed as text, such as
4 JanorJan-04-26, which won't group by month or year.
To check a column, use =ISNUMBER(E2) for numbers or =ISDATE(A2) for dates and fill it down. Any FALSE is a cell to fix.
=ISNUMBER(E2)A quicker check is the count of numeric cells against the count of non-empty cells:
=COUNT(E2:E) & " numeric of " & COUNTA(E2:E) & " filled"If the two numbers differ, some cells in the column are text or blank.
No blank rows or blank columns inside the table
A blank row in the middle of the data doesn't always break a pivot table. It matters when the range is auto-detected, because detection can stop at the gap. The part of the table below the blank row is then left out without any warning. Delete empty rows instead of leaving them as spacers. Blank cells inside a row are fine in themselves, but see the section on missing values below.
No subtotals, totals or notes inside the range
If your sheet has a Total row at the bottom, the pivot table treats it as one more record. Revenue then counts twice: once for the real rows and once for the total. Keep totals outside the source range, or remove them. Do the same for notes, comments, and repeated header rows from pasted reports.
No merged cells
A merged cell holds its value in only the top-left cell. The other rows covered by the merge are empty as far as the pivot table is concerned. A merged West spanning five rows becomes one West and four blanks. Unmerge the cells and fill the value into every row.
To fill blanks left by an unmerge, add a helper column in a spare area:
=ARRAYFORMULA(IF(B2:B="", "", IF(B2:B<>"", B2:B, "")))For a simple fill-down, a more direct method is to select the column, unmerge, and copy the value into each cell with the fill handle. Check the result by filtering for blanks.
Consistent spelling and spacing
A pivot table treats West, west and West (with a trailing space) as different groups. Capitalization differences are usually merged, but extra spaces and typos are not. If you see Widget and Widgets as two rows in the pivot table, the source data has two spellings.
To find and fix stray spaces, use TRIM in a helper column, then paste the results back as values:
=ARRAYFORMULA(TRIM(B2:B))You can also use Data > Data cleanup > Trim whitespace and Data > Data cleanup > Remove duplicates on the selected range. Remove duplicates deletes rows, so make a copy of the sheet first if you aren't sure the duplicates are mistakes.
Handling missing values
Pivot tables don't invent values. A blank in a field you group by shows up as an empty group, or as a row labelled with a blank, depending on the Show totals and Rows settings. A blank in a field you sum is skipped. A blank in a field you count is also skipped, since COUNTA counts only filled cells.
Decide on a rule per column:
- For a category such as Region, fill missing values with a label like
Unknown. This keeps those records visible and easy to find. - For a numeric field such as Revenue, leave true gaps blank so they don't drag down an average. Use
0only when zero is the real value.
This choice affects results. An average over [100, 200, blank] is 150. An average over [100, 200, 0] is 100.
Dates need real date values
If you plan to group by month, quarter or year, the date column must contain real dates. A real date is right-aligned by default and can be reformatted from Format > Number. If you change the format to a plain number and see a value like 46026, it's a real date. If it stays as typed, it's text.
To convert text dates, use DATEVALUE in a helper column:
=ARRAYFORMULA(IF(A2:A="", "", DATEVALUE(A2:A)))Format the result as a date, then paste it back as values over the original column, or point the pivot table at the helper column.
Keep room to grow
Plan for the data to get longer. Two habits help:
- Put the source data on its own sheet, with nothing to its right or below it. The pivot table goes on a different sheet.
- When you select the source range, include whole columns or an open-ended range such as
Sales!A1:F, so new rows are picked up. Later chapters cover how the range updates.
A fixed range such as Sales!A1:F500 stops at row 500. Rows added after that are ignored without a warning.
A pre-flight checklist
Run through this list before you create the pivot table:
| Check | What to look for | Fix |
|---|---|---|
| Header row | One row, no blanks, no duplicates | Rename or merge header rows |
| Column types | Numbers are numbers, dates are dates | `ISNUMBER`, `DATEVALUE`, reformat |
| Blank rows | None inside the table | Delete them |
| Totals and notes | None inside the range | Move them outside |
| Merged cells | None | Unmerge and fill down |
| Spelling | One spelling per category | `TRIM`, find and replace |
| Missing categories | Labelled, not blank | Fill with `Unknown` |
| Range | Open-ended or whole columns | Use `A1:F` |
Common errors from poor source data
- The editor says the range is invalid. A header cell is blank, or the selection includes a fully empty column.
- A numeric field defaults to Count and not Sum. The column contains text, so the pivot table treats it as a text field.
- Totals are double what you expect. A totals row is inside the range.
- Some groups are missing. The range ended early, or a blank row stopped detection.
- Two rows for the same category. Different spelling, or trailing spaces.
- Dates can't be grouped. The date column holds text.
Exercise
A source sheet has Revenue values in E2:E200. =COUNT(E2:E200) returns 190 and =COUNTA(E2:E200) returns 199. The pivot table's Revenue total looks too low. What is the likely cause, and how would you fix it?
Show answer
Nine cells in the column are filled but not numeric (199 filled minus 190 numeric). They are probably numbers stored as text, or placeholders such as "n/a". The pivot table sums only numeric cells, so the total is low. Use ISNUMBER in a helper column to find the nine cells, then convert them to real numbers (remove symbols or apostrophes) or clear the placeholders, and refresh the pivot table.
Exercise
Your source table has a "Total" row at the bottom, and the pivot table's grand total is exactly double the sum of the real records. Why, and what are two ways to fix it?
Show answer
The Total row is part of the source range, so it is counted as one more record alongside the rows it summarizes. Fix it by deleting the Total row or moving it outside the source range, or by changing the pivot table's data range so it ends before the Total row.