Short answer: To make a pivot table in Excel, put one header row over clean data, click any cell in it, choose Insert → PivotTable, accept New Worksheet, then drag a category field to Rows and a number field to Values. If Values shows Count, find text with =SUMPRODUCT(--ISTEXT(E2:E500)) and switch it to Sum.

What must your source data look like before you make a pivot table?

The source needs one header row, one record per row, and one data type per column. Check four things:

  • Every column has a unique header in row 1 (SKU, Order Date, Region, Category, Revenue). A blank header gives the error 'PivotTable field name is not valid'.
  • No fully blank rows or columns inside the data. Excel picks the range by stopping at the first fully blank row, so everything below it is silently left out.
  • No merged cells. A merged Region cell leaves every row after the first with an empty region.
  • No subtotal or Total rows. The pivot counts them as sales and doubles your totals. ERP exports that add a Total every ten lines need those rows deleted.

If the pivot's grand total disagrees with =SUM(E2:E500), look for a blank row or a Total row first.

How do you insert a pivot table?

Click any cell in the data, choose Insert → PivotTable, check that the range covers every header and row, choose New Worksheet, and click OK.

A new sheet opens with an empty pivot and a Field List on the right. A new sheet keeps the pivot from sitting on top of your source data. If the Field List disappears, right-click the pivot and choose Show Field List.

Which fields go in Rows, Columns, Values and Filters?

Rows are the groups you read down the left side, Columns are a second grouping across the top, Values is the number being calculated, and Filters is a drop-down that limits the whole report.

A starting layout for a sales file: Rows = Category (Outdoor Furniture, Office Supplies), Columns = Region (North, South, West), Values = Revenue. That gives revenue by category across regions.

Put the field with more distinct values in Rows. With 40 categories and 4 regions, flipping them gives 40 columns and 4 rows, which is unreadable and prints badly. For a single breakdown, such as revenue per sales rep, put the rep in Rows, Revenue in Values, and leave Columns empty. To nest groups, drag a second field under the first in Rows, such as Category then SKU. Drag Year into Filters if you want one drop-down for the whole report.

Why does the pivot show Count of Revenue instead of Sum, and how do you fix it?

Excel defaults to Count when the Values column contains any text or any blank cell, because it cannot confirm the column is numeric. A text field dragged into Values also gives Count, which is useful on purpose: Count of Order ID is your order volume.

To find the offending cells in a Revenue column in E2:E500:

  • Text cells: =SUMPRODUCT(--ISTEXT(E2:E500)). Anything above 0 means text numbers are in there.
  • Blank cells: =COUNTBLANK(E2:E500).

Supplier feeds often contain non-breaking spaces (character 160) that TRIM alone does not remove. In a helper column, copy this down:

=IF(TRIM(SUBSTITUTE(E2,CHAR(160)," "))="","",VALUE(TRIM(SUBSTITUTE(E2,CHAR(160)," "))))

Paste the results over the original column with Paste Special → Values. Cells that came back as "" are now empty text, not empty cells, and still cause Count. Filter for blanks and press Delete on them.

Then refresh the pivot. Excel does not switch back to Sum by itself, so right-click a value cell → Value Field Settings → Sum.

How do you change the calculation, and how do you show margin?

Right-click any value cell, choose Value Field Settings, and pick Sum, Count, Average, Max or Min.

You can drag the same field into Values twice, for example Revenue as Sum and Revenue as Average. The Show Values As tab adds % of Grand Total, % of Column Total, Running Total and Rank, each of which would otherwise need a column of formulas.

For margin, drag Revenue and Cost into Values to see them side by side. For margin %, do not average per-line percentages, because small orders get the same weight as large ones. Add a calculated field instead: PivotTable Analyze → Fields, Items & Sets → Calculated Field, name it Margin, and enter =IF(Revenue=0,0,(Revenue-Cost)/Revenue). It sums first and then divides, so each row shows the true margin on its total revenue.

How do you group dates by month, quarter or year?

Right-click any date in Rows, choose Group, and select Months, Quarters, Years or a combination. Selecting Quarters and Years together gives a collapsible hierarchy.

Always include Years when your data spans more than one year. Grouping by Months alone merges January 2023 and January 2024 into one row.

Excel 2016 and later group dates automatically when you add the field to Rows, choosing the level from the date span. Right-click → Ungroup undoes it, and File → Options → Data has a setting to turn automatic grouping off. In Excel 2013 and earlier you group manually.

If Excel says 'Cannot group that selection', the date column contains text dates or blank cells. Test it with =SUMPRODUCT(--ISTEXT(B2:B500)) and =COUNTBLANK(B2:B500). To convert text dates, select the column, use Data → Text to Columns, click Next twice, choose Date in step 3, and pick DMY or MDY to match your data. Then refresh.

How do you keep a pivot table up to date when the data changes?

Convert the source to a Table with Ctrl+T before you build the pivot, then refresh the pivot with Alt+F5 whenever the data changes.

Tick 'My table has headers', then type a name such as tblSales in the Table Name box on the Table Design tab. Under Table Tools → Design in Excel 2010, the box is at the far left. Select a cell in the Table and insert the pivot; the source box shows tblSales. A Table adds new rows and columns to the source automatically, but it does not refresh the pivot for you.

A pivot built on a plain range is fixed at something like Sheet1!$A$1:$F$500. Rows added at row 501 are ignored, even after a refresh, until you extend the range under PivotTable Analyze → Change Data Source.

  • Refresh one pivot: right-click → Refresh or Alt+F5.
  • Refresh every pivot in the workbook: Data → Refresh All or Ctrl+Alt+F5.
  • Refresh on file open: PivotTable Options → Data → 'Refresh data when opening the file'.

How do you format a pivot table so the formatting survives?

Set number formats through Value Field Settings → Number Format, not by formatting cells directly. Field-level formatting follows the field when the layout changes, while direct cell formatting does not.

To keep column widths and styles after a refresh, open PivotTable Options → Layout & Format and tick 'Preserve cell formatting on update'. To remove a (blank) row label, either filter it out in the Row Labels drop-down or fill the empty source cells.

What is different in Excel 2010, 2013 and Excel 365?

The drag-and-drop workflow is identical in every version. The differences are in the extras.

  • Excel 2010 has no Recommended PivotTables button and no Timeline filter. Both arrived in Excel 2013. Slicers exist in 2010 (PivotTable Tools → Options → Insert Slicer). Power Pivot is a separate free add-in. In 2010 you always start from Insert → PivotTable.
  • A workbook saved as .xls, or open in Compatibility Mode, is capped at 65,536 rows, and data beyond that is cut off. Save as .xlsx before building the pivot. Old ERP exports often arrive as .xls.
  • Excel 365 adds Insert → PivotTable → From Data Model for multi-table setups, and an Analyze Data button on the Home tab that suggests layouts.
  • On Mac the steps are the same, but the Field List can render narrow. Drag its left edge to widen it.

Should you use a pivot table or SUMIFS?

Use a pivot table to explore data or when categories change over time, and use SUMIFS when the layout is fixed and feeds other formulas.

A pivot picks up new SKUs, regions and months on refresh, and it groups dates without helper columns. A typed reference into a pivot cell breaks when the pivot is sorted or filtered. For a single stable number, such as revenue for SKU-4821 in Q3 2024, query the source:

=SUMIFS($E$2:$E$500,$A$2:$A$500,"SKU-4821",$B$2:$B$500,">="&DATE(2024,7,1),$B$2:$B$500,"<"&DATE(2024,10,1))

If you do need a number out of a pivot, click the cell and let Excel write the GETPIVOTDATA formula. It follows the value even when the layout moves. If the real problem is cleaning or reshaping data rather than summarising it, use Power Query.

Frequently asked

Can I have two pivot tables from the same source data?

Yes. Insert a second pivot on the same range or Table, leaving room so the two do not overlap. Layouts are independent, but pivots from the same source share a cache, so grouping dates in one also groups them in the other.

How do I remove the grand total?

Go to PivotTable Design → Grand Totals and choose Off for Rows and Columns, or turn off just rows or just columns.

Does refreshing or deleting a pivot table change my source data?

No. Refresh only re-reads the source range, and deleting the pivot leaves the data untouched. Pulling live data from an external database needs a data connection or Power Query.

Originally published at DataRoutine.work, where the guide is kept up to date.