Lesson 26 of 92 · Free Excel Course
Excel
Pivot Tables in Excel: How to Create a Pivot Table, Step by Step
Create a pivot table in Excel, use Rows, Columns, Values and Filters, group dates, refresh it and use GETPIVOTDATA. Free practice workbook with answers.
Say you have a list of 36 sales and your boss asks, "How much did each region sell?" You could write a formula for each region, or you could build a pivot table in about ten seconds. A pivot table takes a long list and turns it into a short summary: totals by region, by product, by month, or all three at once. You don't write any formulas, and you can rearrange the whole report by dragging a field from one box to another. This lesson builds one from scratch, explains every box in the field list, and shows how to group dates, show percentages, refresh, and use the GETPIVOTDATA formula.
Get your data ready
Here's the start of the practice data: 36 sales from January to June 2026, in A1:F37.
| A | B | C | D | E | F | |
|---|---|---|---|---|---|---|
| 1 | Date | Region | Rep | Product | Units | Sales |
| 2 | 1/4/2026 | East | Ben | Desks | 4 | $720 |
| 3 | 1/8/2026 | West | Carla | Chairs | 2 | $90 |
| 4 | 1/12/2026 | West | Dev | Lamps | 6 | $180 |
| 5 | 1/16/2026 | North | Ella | Desks | 3 | $540 |
| 6 | 1/20/2026 | South | Femi | Chairs | 5 | $225 |
| 7 | 1/24/2026 | East | Ann | Lamps | 1 | $30 |
Check four things before you start:
- One header row, with a different name in every column. Each heading becomes a field you can drag.
- No blank rows or columns inside the data. A blank row can make Excel stop the range early.
- No totals or subtotals in the list. The pivot does the adding up; extra total rows get counted twice.
- The same kind of value all the way down a column. Real dates in the Date column and real numbers in Sales (see Dates and times if your dates are text).
Ideally, turn the list into an Excel table first (click a cell, press Ctrl+T). A table grows when you add rows, so the pivot picks up new sales when you refresh.
Insert a pivot table
- Click any single cell in the list.
- On the Insert tab, click PivotTable. If a menu opens, choose From Table/Range.
- Check the range in the box. It should be
A1:F37(or the table's name, such asTable1). - Choose New Worksheet (the tidiest option) or Existing Worksheet and click a cell for it.
- Click OK.
Excel adds a new sheet with an empty pivot placeholder on the left and the PivotTable Fields pane on the right. The top half of the pane lists your headings; the bottom half has four boxes.
Not sure what to build? Insert, then Recommended PivotTables, shows a few ready-made summaries of your data. Click one and choose OK, and Excel puts it on a new sheet. It's a good way to see what's possible, and you can change it afterwards.
On a Mac, the steps are the same: Insert, PivotTable, confirm the range, choose a sheet, OK. In Excel for the web, Insert, then PivotTable, opens an Insert PivotTable pane: choose New sheet or Existing sheet on the "Create your own PivotTable" card. The recommended pivots in that pane are only available to Microsoft 365 subscribers.
The four areas: Filters, Columns, Rows and Values
The four boxes at the bottom of the field list decide what the pivot shows:
| Area | What it does | Example |
|---|---|---|
| Rows | One row per item, down the left | Region gives East, North, South, West |
| Columns | One column per item, across the top | Product gives Chairs, Desks, Lamps |
| Values | The numbers that get summed, counted or averaged | Sales |
| Filters | A drop-down above the pivot that filters the whole report | Rep, to show one person at a time |
The quickest way to add a field is to tick its box. Excel puts text fields in Rows and number fields in Values. To put a field somewhere else, drag it between boxes; to remove it, untick it or drag it out of the pane.
Tick Region, then Sales:
| A | B | |
|---|---|---|
| 3 | Row Labels | Sum of Sales |
| 4 | East | 3750 |
| 5 | North | 1455 |
| 6 | South | 1770 |
| 7 | West | 5085 |
| 8 | Grand Total | 12060 |
West sold the most, North the least. Excel lists the regions A to Z and labels the headers Row Labels and Sum of Sales. The dollar signs come later.
Now drag Product into Columns. The pivot becomes a two-way grid with a total for every row and every column:
| A | B | C | D | E | |
|---|---|---|---|---|---|
| 3 | Sum of Sales | Column Labels | |||
| 4 | Row Labels | Chairs | Desks | Lamps | Grand Total |
| 5 | East | 630 | 2700 | 420 | 3750 |
| 6 | North | 225 | 900 | 330 | 1455 |
| 7 | South | 450 | 900 | 420 | 1770 |
| 8 | West | 495 | 3960 | 630 | 5085 |
| 9 | Grand Total | 1800 | 8460 | 1800 | 12060 |
Put Rep in Filters and a drop-down appears above the pivot (in A1); pick Carla and every number changes to just her sales. Choose (All) to go back.
Sum, Count, Average and % of Grand Total
Values are added up (Sum) by default. To change what Excel calculates:
- Right-click any number in the pivot and choose Value Field Settings (or click the field in the Values box, then Value Field Settings).
- On the Summarize Values By tab, choose Sum, Count, Average, Max, Min and so on. Count of Sales gives the number of orders: East 12, North 6, South 6, West 12. Average gives East $312.50 per order.
- Click Number Format, choose Currency with 0 decimal places, and click OK twice. Now the pivot shows $3,750 instead of 3750, and the format stays when you refresh.
Why does it say Count of Sales when I wanted Sum? Excel only defaults to Sum when it sees numbers. If the Sales column has a blank cell, or numbers stored as text (often from a pasted report), it chooses Count. Switch it to Sum, then fix the data so it doesn't happen again.
Show Values As turns totals into comparisons. Right-click a number, choose Show Values As, then % of Grand Total. East becomes 31.09%, North 12.06%, South 14.68%, West 42.16%, and the Grand Total 100.00%. Other choices include % of Column Total, Running Total In and Rank Largest to Smallest. Choose No Calculation to go back to plain totals.
On a Mac, click the arrow next to the field in the Values box and choose Field Settings, with Summarize by and Show data as options. In Excel for the web, right-click a number and use Summarize Values By or Show Values As.
Group dates by month and quarter
Untick Region and tick Date instead. In Excel for Microsoft 365 the dates usually group by month on their own. If you see 36 separate dates:
- Right-click any date in the pivot (not in your source list) and choose Group.
- Under By, click Months, then also click Quarters. Leave Starting at and Ending at as they are.
- Click OK.
| A | B | |
|---|---|---|
| 3 | Row Labels | Sum of Sales |
| 4 | Qtr1 | 6000 |
| 5 | Jan | 1785 |
| 6 | Feb | 1755 |
| 7 | Mar | 2460 |
| 8 | Qtr2 | 6060 |
| 9 | Apr | 1965 |
| 10 | May | 2235 |
| 11 | Jun | 1860 |
| 12 | Grand Total | 12060 |
To undo it, right-click a month and choose Ungroup. If Group is greyed out or gives an error, at least one cell in the Date column is text or blank. Your data has more than one year? Select Years too, or Jan 2025 and Jan 2026 get added together.
Sort, filter and slicers
- Sort by value: swap Date for Rep, right-click a number and choose Sort, then Sort Largest to Smallest. Carla ($2,670) goes to the top and Ann ($1,335) to the bottom.
- Filter the rows: click the arrow on Row Labels and untick items, or use Value Filters (such as Top 10) for the biggest few. It works like the filters in Sort and filter.
- Slicers are big filter buttons you can click. Click inside the pivot, go to PivotTable Analyze and click Insert Slicer (it's also on the Insert tab as Slicer), tick Product and click OK. Click Desks and the pivot shows only desk sales (West $3,960). Ctrl+click to pick more than one (Cmd+click on a Mac), and click the Clear Filter button on the slicer to show everything again. In Excel for the web, it's PivotTable Analyze, then Slicer.
Refresh: pivots don't update on their own
Change F2 in the data from 720 to 1720, go back to the pivot, and nothing has changed. A pivot reads a saved copy of your data until you tell it to look again.
- Refresh one pivot: right-click inside it and choose Refresh, or press Alt+F5.
- Refresh everything: PivotTable Analyze, click the arrow under Refresh, then Refresh All, or press Ctrl+Alt+F5.
- Refresh every time the file opens: PivotTable Analyze, Options, then the Data tab, and tick Refresh data when opening the file.
After refreshing, East shows 4750 and the Grand Total 13060. On a Mac, use PivotTable Analyze, then Refresh, or Control-click the pivot. In Excel for the web, right-click and choose Refresh, or use Refresh All on the PivotTable tab.
GETPIVOTDATA: the formula that appears when you click a pivot
Type = in a cell outside the pivot, click West's total (B7), and press Enter. Instead of =B7, Excel writes:
| A | B | C | D | |
|---|---|---|---|---|
| 3 | Row Labels | Sum of Sales | West total | |
| 4 | East | 3750 | 5085 | |
| 5 | North | 1455 | ||
| 6 | South | 1770 | ||
| 7 | West | 5085 | ||
| 8 | Grand Total | 12060 |
The syntax is =GETPIVOTDATA(data_field, pivot_table, [field1, item1], ...):
- data_field is the value field in quotes:
"Sales"("Sum of Sales"works too). - pivot_table is any cell inside the pivot, here
$A$3. - field1, item1 pairs say which number you want:
"Region","West". Add more pairs, such as"Product","Desks", to narrow it down (that gives 3960).
Why does Excel do this? A normal =B7 breaks as soon as the pivot is sorted or a region is added, because West moves. GETPIVOTDATA always finds West's total wherever it is. If the item isn't showing (filtered out or not in the data), it returns #REF!. The item can also be a cell, as in =GETPIVOTDATA("Sales",$A$3,"Region",F2).
Turn it off if you'd rather get plain references: click inside the pivot, go to PivotTable Analyze, click the small arrow next to Options (in the PivotTable group), and untick Generate GetPivotData. Tick it again whenever you want the formulas back.
Pivot charts
Click inside the pivot, then Insert, PivotChart, pick a chart such as Clustered Column and click OK. The chart follows the pivot: filter or use a slicer and the chart changes as well. On a Mac and in Excel for the web, build the pivot first, then insert a normal chart from the Insert tab while a pivot cell is selected. Chart types and formatting work as in Charts and graphs.
Try it yourself
Download the practice workbook. The Your task sheet has the steps; the Practice sheet has the 36 sales.
- Insert a pivot on a new sheet and add Region and Sales. Check: East 3750, Grand Total 12060.
- Drag Product to Columns, then take it out again.
- Show Values As % of Grand Total, then Summarize Values By Count (East 12 orders). Put it back to Sum.
- Put Date in Rows and group by Months and Quarters (Qtr1 6000, Qtr2 6060).
- Swap in Rep, sort largest to smallest, then add a Product slicer and click Desks.
- Change F2 to 1720, refresh, and type
=then click West's total to see GETPIVOTDATA.
The Answer key sheet shows all seven expected pivots. The Answers sheet has SUMIFS and COUNTIFS formulas that produce the same numbers, so you can prove your pivot right.
Common mistakes
- Forgetting to refresh. The pivot shows old numbers until you refresh it.
- New rows left out. With a plain range, rows you add below aren't included. Use an Excel table, or change the range with PivotTable Analyze, Change Data Source.
- Totals inside the data. A Total row in the source gets added in again, doubling the Grand Total.
- Count instead of Sum. Blank or text cells in a number column. Fix the data, then switch back to Sum.
- Typing into the pivot. You can't change a number inside a pivot by typing over it. Change the source data and refresh.
- Blank headings. Every column needs a heading, or Excel refuses to build the pivot.
What's next
You can now turn a long list into a summary, slice it any way you like, and keep it up to date. The previous lesson, Charts and graphs, shows how to turn summaries into pictures. Next, Printing shows how to get a sheet like this onto paper or a PDF that looks right. You can also go back to the full Excel course.
Frequently asked questions
Why does my pivot table show Count instead of Sum?
Excel picks Count when it thinks the column isn't all numbers, usually because it has a blank cell or a number stored as text. Right-click any value in the pivot, choose Summarize Values By, then Sum. For a lasting fix, fill the blanks (with 0 if that's correct) and convert text-numbers back to numbers, then refresh.
Why doesn't my pivot table update when I change the data?
A pivot table works from a snapshot of your data, so it only changes when you refresh it. Right-click inside the pivot and choose Refresh, or press Alt+F5. Ctrl+Alt+F5 refreshes everything in the workbook. If you added new rows below the data, they're only picked up automatically when the source is an Excel table.
How do I group dates by month in a pivot table?
Put the date field in Rows. Excel for Microsoft 365 usually groups it by month for you. If you see every single date instead, right-click one of them, choose Group, select Months (and Quarters or Years if you want them) and click OK. If Group is greyed out, some cells in the date column are text or blank.
What is GETPIVOTDATA and how do I stop Excel creating it?
GETPIVOTDATA is the formula Excel writes when you type = and click a number inside a pivot table, for example =GETPIVOTDATA("Sales",$A$3,"Region","West"). It finds the number by its labels, so it doesn't break when the pivot moves. To get normal references like =B7 instead, click in the pivot, go to PivotTable Analyze, click the arrow next to Options and untick Generate GetPivotData.
Should I use a pivot table or SUMIFS?
Use a pivot table to explore and summarise quickly: drag a field and you have a new report, and it needs refreshing. Use SUMIFS and COUNTIFS when you need a fixed report layout that recalculates by itself. The practice workbook has both, so you can see they give the same numbers.
Can I make a pivot table in Excel for the web or on a Mac?
Yes. On a Mac it's Insert, then PivotTable, and value settings are under Field Settings. In Excel for the web, Insert, then PivotTable opens a side pane where you choose a new or existing sheet; the recommended pivots there need a Microsoft 365 subscription. You can use Excel for the web for free; see how to get Excel free.