Pivot tables in Excel: how to create one and use it

To create a pivot table in Excel, click any cell in your data, then on the Insert tab choose PivotTable. Check the range, choose New Worksheet and click OK. In the PivotTable Fields pane that opens, tick a field to group by, such as Region, and a field of numbers, such as Amount. Excel lists each region once and adds up its amounts, without a formula.

This guide builds a pivot table from a small sales table, step by step: what a pivot table is, how to create one and how to change what it shows. Then it covers counts, averages and percentages, grouping dates by month, sorting and filtering, refreshing, calculated fields and the formulas that give the same numbers. After that come 11 exercises to practise them.

Every number on this page comes from the practice sheet our lessons use. A pivot table adds up and counts by the same rules as SUMIFS and COUNTIFS, so we ran those formulas through it and printed what they returned.

What a pivot table is

A pivot table, which Excel calls a PivotTable, summarises a table of data without any formulas. You choose the column to group by and the column to add up, and Excel builds the summary on a new sheet or beside your data. The data itself doesn’t change.

This table has twelve sales, one to a row:

Twelve sales, one to a row: the date, region, rep, product, units sold and amount
ABCDEF
1DateRegionRepProductUnitsAmount
26 Jan 2026NorthAshaDesk2290
39 Jan 2026SouthBenChair4356
414 Jan 2026NorthKofiLamp10245
522 Jan 2026WestDaraDesk3435
63 Feb 2026SouthLinaLamp6147
710 Feb 2026NorthAshaChair5445
817 Feb 2026WestDaraChair2178
924 Feb 2026SouthBenDesk4580
104 Mar 2026NorthKofiDesk3435
1111 Mar 2026WestDaraLamp8196
1218 Mar 2026SouthLinaChair2178
1326 Mar 2026NorthAshaLamp12294

Put Region in the pivot table’s rows and Amount in its values, and Excel lists each region once with the total of its sales:

Row LabelsSum of Amount
North1,709
South1,261
West809
Grand Total3,779

Twelve rows become three, plus a grand total. Drag Product into the columns and each region’s total splits by product. Swap Region for Rep and the same pivot table shows each rep’s sales. Turning the data around like this, to see it another way, is the pivot in the name.

How to create a pivot table in Excel

Get your data ready

A pivot table reads your data as a list: one row for each sale, order or entry, and one column for each detail. Before you start, check that it has:

  • One row of headings, with a different heading over every column and none left blank. Excel won’t build a pivot table from a range with a blank heading.
  • One kind of data in each column: dates as dates and numbers as numbers. A column of numbers with text in it is counted instead of added up.
  • No empty rows or columns, merged cells or subtotals inside the data.

It also helps to make the data a table: click a cell in it, press Ctrl+T and click OK. A pivot table built on a table takes in the rows you add to it when you refresh.

Insert the pivot table

  1. Click any cell in the data: one in A1:F13 here.
  2. On the Insert tab, choose PivotTable. On Windows, pressing Alt, then N, V and T opens it from the keyboard.
  3. Check the range, choose New Worksheet and click OK. Excel adds a sheet with an empty pivot table at A3, and the PivotTable Fields pane beside it.
  4. Tick the fields to show: Region, then Amount.

Ticking a field puts it in one of the boxes at the bottom of the pane: text goes to Rows and numbers to Values. Drag a field from one box to another to move it, or untick it to take it out. The pane shows whenever a cell in the pivot table is selected. If you’ve closed it, right-click the pivot table and choose Show Field List.

Excel for Mac has PivotTable on the Insert tab too, and in Excel for the web the same choices open in a pane at the side. On Windows, Recommended PivotTables, next to PivotTable, offers a few ready-made pivot tables for your data, which can be a quicker start.

Rows, Columns, Values and Filters

The four boxes at the bottom of the pane decide what the pivot table shows.

AreaWhat it doesIn the example
RowsLists each item once, down the side.Region: North, South and West
ColumnsLists each item once, across the top.Product: Chair, Desk and Lamp
ValuesAdds up, counts or averages a field for each row and column.Amount, added up
FiltersPuts a filter above the pivot table, to choose which rows of data it covers.Rep, to see one rep’s sales

With Region in Rows, Product in Columns and Amount in Values, each number is the sales for one region and one product, with totals for both:

Row LabelsChairDeskLampGrand Total
North4457255391,709
South5345801471,261
West178435196809
Grand Total1,1571,7408823,779

South’s desk sales came to 580, for example. Each of those numbers is a total with two conditions, the job SUMIFS does with a formula. Try SUMIFS in your browser: this task comes from lesson 27 of Excel Foundations, our free course, and it checks your formula the way the course does.

In B11, total the paid Travel expenses.

Example data for this task
ABCD
1ItemCategoryAmountPaid
2Taxi to airportTravel42.50Yes
3Team lunchMeals86.00No
4Hotel, 2 nightsTravel310.00Yes
5Printer inkOffice38.90Yes
6Client dinnerMeals124.00Yes
7Train ticketTravel27.00No
8NotebooksOffice15.60No
9
10Unpaid travel1
11Paid travel total (your answer goes here)
12Paid over 100

Create a free account to carry on with the rest of Excel Foundations.

Put two fields in Rows, such as Region and then Rep, and each region lists its reps underneath, with a subtotal for the region. The order of the fields in the box sets the order of the levels.

To show part of the data, drag a field to Filters. With Rep there, a filter appears above the pivot table: pick Asha and it shows only her sales, 1,029 in all.

A new pivot table puts every field in Rows in one column, under the heading Row Labels. To give each field a column and a heading of its own, go to the Design tab and choose Report Layout, then Show in Tabular Form. Repeat All Item Labels, on the same menu, fills in the gaps under each region, which helps when you copy the result somewhere else.

Make a pivot chart

Click the pivot table, then on the PivotTable Analyze tab choose PivotChart, pick a chart and click OK. The chart shows the same fields as the pivot table, so filtering or rearranging one changes the other.

Sum, count, average or percentage

Change the calculation

Excel adds up a field of numbers and counts anything else. To change that, right-click a number in the pivot table, choose Summarize Values By and pick Count, Average, Max or Min. More Options lists the rest. The heading changes with it, from Sum of Amount to Count of Amount.

Row LabelsCount of AmountAverage of Amount
North5341.80
South4315.25
West3269.67
Grand Total12314.92

To show both, as here, drag Amount into Values a second time and change only the second one. Count gives the number of sales, and Average the size of the average sale. To change how the numbers look, such as two decimal places, right-click one and choose Number Format.

Average of Amount is what AVERAGEIF works out for one group. This task comes from lesson 26 of Excel Foundations.

In B10, work out the average Meals expense.

Example data for this task
ABCD
1ItemCategoryAmountPaid
2Taxi to airportTravel42.50Yes
3Team lunchMeals86.00No
4Hotel, 2 nightsTravel310.00Yes
5Printer inkOffice38.90Yes
6Client dinnerMeals124.00Yes
7Train ticketTravel27.00No
8NotebooksOffice15.60No
9
10Average meal (your answer goes here)

Create a free account to practise the rest of Excel Foundations.

Count unique values

Count of Rep counts rows, not people: North’s 5 sales came from 2 reps. To count each rep once, tick Add this data to the Data Model when you create the pivot table, and drag Rep into Values. Then right-click a number in the Count of Rep column, choose Value Field Settings and pick Distinct Count, at the bottom of the list.

Row LabelsCount of RepDistinct Count of Rep
North52
South42
West31
Grand Total125

Distinct Count only appears in pivot tables built on the Data Model, which Excel for Windows has. If it isn’t in your list, as on a Mac or in Excel for the web, count with a formula instead. In Excel 2021 and later, Microsoft 365 and the web, =COUNTA(UNIQUE(FILTER(C2:C13,B2:B13="North"))) gives North’s 2.

Show percentages

Right-click a number, choose Show Values As, then % of Grand Total, and each region’s sales show as a share of all sales. To see the amount beside its share, drag Amount into Values twice, as before, and change only the second. It’s called Sum of Amount2 until you click its heading and type a name over it, such as Share.

Row LabelsSum of AmountShare
North1,70945.2%
South1,26133.4%
West80921.4%
Grand Total3,779100.0%

With products across the top, % of Row Total gives each product’s share of a region’s sales, and % of Column Total each region’s share of a product’s. Show Values As also has running totals, ranks and the difference from another item, such as the month before. Our guide to percentage formulas works out the same shares with formulas.

Group dates by month

In Excel 2016 and later, adding a date field to a pivot table groups the dates by itself: into months and, for longer spans, quarters and years. To choose the grouping yourself, right-click a date in the pivot table, choose Group, select Months and click OK. With Date in Rows and Amount in Values:

Row LabelsSum of Amount
Jan1,326
Feb1,350
Mar1,103
Grand Total3,779

When the dates cover more than one year, select Years as well as Months. With Months alone, January 2025 and January 2026 are added up in one row. To turn the automatic grouping off, go to File, Options, Data and tick Disable automatic grouping of Date/Time columns in PivotTables.

Group works on numbers too. Right-click a number in Rows, such as an amount, choose Group, and set where the bands start and end and how wide each one is. To group items by hand, such as two regions into one, select them with Ctrl, right-click and choose Group.

Sort and filter a pivot table

Sort by value

A pivot table lists its items from A to Z: Chair, Desk, Lamp. To put the best seller first, right-click a number in the Sum of Amount column, choose Sort, then Sort Largest to Smallest. With Product in Rows:

Row LabelsSum of Amount
Desk1,740
Chair1,157
Lamp882
Grand Total3,779

To sort them by name again, click the arrow on the Row Labels heading and choose Sort A to Z.

Show the top items

Click the arrow on the Row Labels heading and choose Value Filters, then Top 10. Leave the first box on Top, set the number to 1 and the next box to Items, and the pivot table shows only Desk. Bottom and Percent work the same way.

Filter with a slicer

A field in Filters gives the pivot table a drop-down above it, as with Rep earlier. A slicer does the same job with buttons: click the pivot table, then on the PivotTable Analyze tab choose Insert Slicer, tick Region and click OK. Click North and the pivot table shows only North’s sales, 1,709 in all. Ctrl and click picks more than one, and the button at the top right of the slicer clears it. For dates, Insert Timeline, next to Insert Slicer, adds a bar that picks months, quarters or years.

Refresh a pivot table when the data changes

A pivot table doesn’t change when its data does. Change an amount in the table and the pivot table keeps the old total until you refresh it: right-click it and choose Refresh, or press Alt+F5. To refresh every pivot table in the file, go to the PivotTable Analyze tab, click the arrow under Refresh and choose Refresh All.

To refresh it each time the file opens, go to PivotTable Analyze, then Options, and on the Data tab tick Refresh data when opening the file. Newer builds of Microsoft 365 add an Auto Refresh button, which updates a pivot table by itself when data in the same workbook changes. Microsoft’s help page lists it for members of the Microsoft 365 Insider programme.

Add new rows

Refresh reads the range the pivot table was built from, so rows added below it stay out. There are two ways round it:

  • Build it on a table. A table grows as you add rows, and refreshing a pivot table takes in the new and changed rows. To move an existing pivot table over, make the data a table with Ctrl+T, then change its source as below.
  • Change the source. On the PivotTable Analyze tab, choose Change Data Source, select the whole range, new rows included, and click OK.

Add a calculated field

A calculated field is a field the pivot table works out from others, without a new column in your data. To show the price per unit:

  1. Click the pivot table. On the PivotTable Analyze tab, choose Fields, Items & Sets, then Calculated Field.
  2. Type a name, such as Price.
  3. Build the formula: delete the 0, double-click Amount, type / and double-click Units, so the box reads =Amount/Units.
  4. Click Add, then OK. Sum of Price appears in Values.
Row LabelsSum of Price
Chair89.00
Desk145.00
Lamp24.50
Grand Total61.95

Each product always sells at one price, so the field gives it back: the total amount over the total units. With Region in Rows instead, it gives each region’s average price per unit, 53.41 for North.

A calculated field works on totals

Microsoft’s rule is that a calculated field works on the sums of the fields in it, not row by row. That suits Price, but not a rule for each sale. Say the reps earn 5% on any sale over 500. A calculated field of =IF(Amount>500,Amount*5%,0) tests each region’s total, and every region’s total is over 500, so every region shows a bonus. Only one sale was over 500:

FormulaWhat it doesResult
=IF(SUM(F2:F13)>500,SUM(F2:F13)*5%,0)The calculated field’s grand total: the total of all sales is over 500, so it takes 5% of the lot.188.95
=SUMPRODUCT((F2:F13>500)*F2:F13)*5%The bonus the reps earned: 5% of the one sale over 500.29.00

To work something out for each row, add a column to the data instead, such as =IF(F2>500,F2*5%,0) filled down, and put that column in Values.

Pivot tables and formulas

Check a pivot table with SUMIFS

A pivot table adds up, counts and averages by the same rules as SUMIFS, COUNTIFS and AVERAGEIFS, so a formula can check any number in it, or put that number where a pivot table can’t go, such as one cell of a report. Each formula below gives a number from the pivot tables above.

FormulaWhat it doesResult
=SUMIFS(F2:F13,B2:B13,"North")North’s total: Sum of Amount in the North row.1,709
=SUMIFS(F2:F13,B2:B13,"North",D2:D13,"Desk")North’s desk sales.725
=COUNTIFS(B2:B13,"North")How many sales North made: Count of Amount.5
=AVERAGEIFS(F2:F13,B2:B13,"North")North’s average sale: Average of Amount.341.80
=SUMIFS(F2:F13,B2:B13,"North")/SUM(F2:F13)North’s share of all sales: % of Grand Total.45.2%
=SUMIFS(F2:F13,A2:A13,">="&DATE(2026,1,1),A2:A13,"<"&DATE(2026,2,1))January’s sales: dates from 1 January, up to but not including 1 February.1,326

Try SUMIF here, the one-condition version of SUMIFS. This task comes from lesson 25 of Excel Foundations.

In B10, total the Travel expenses.

Example data for this task
ABCDEFG
1ItemCategoryAmountPaidCategoryTotal
2Taxi to airportTravel42.50YesMeals
3Team lunchMeals86.00No
4Hotel, 2 nightsTravel310.00Yes
5Printer inkOffice38.90Yes
6Client dinnerMeals124.00Yes
7Train ticketTravel27.00No
8NotebooksOffice15.60No
9
10Travel total (your answer goes here)
11Unpaid total

Create a free account to practise the rest of Excel Foundations.

GETPIVOTDATA

Type = and click a number inside a pivot table, and Excel writes a GETPIVOTDATA formula in place of a cell address, such as =GETPIVOTDATA("Amount",$A$3,"Region","North"). It returns North’s total, 1,709, wherever that number moves when the pivot table changes. To get plain cell addresses instead, click the pivot table, then on the PivotTable Analyze tab click the arrow next to Options and untick Generate GetPivotData.

GROUPBY and PIVOTBY

Microsoft 365 has two functions that build a summary with a formula. =GROUPBY(B2:B13,F2:F13,SUM) lists each region once with its total, as the first pivot table does, and =PIVOTBY(B2:B13,D2:D13,F2:F13,SUM) adds the products across the top. Microsoft notes that PIVOTBY isn’t directly related to the PivotTable feature. Their results change as soon as the data does, with nothing to refresh, and you change them by editing the formula rather than by dragging fields.

A pivot table suits exploring: a field in Rows, then another, a filter, a grouping by month. Formulas suit a summary that stays in one place, such as a report that’s laid out once and updated every month.

When a pivot table goes wrong

  • The PivotTable field name is not valid. A column in the range has no heading, often an empty column at the edge of the selection. Type a heading, or select only the data.
  • New rows are missing. Refresh only reads the range the pivot table was built from. Build it on a table, or use Change Data Source, then refresh.
  • It counts instead of adding up. The column holds text, such as numbers stored as text or a note like n/a, or it has empty cells. Fix the data, then choose Sum with Summarize Values By.
  • (blank) shows as an item. Some cells in that column are empty, or the range takes in empty rows below the data. Fill the cells in, or untick (blank) with the arrow on Row Labels.
  • Cannot group that selection. The date column holds text or empty cells, so Excel can’t read it as dates. Turn the text into real dates, then refresh.
  • Cannot change this part of a PivotTable report. Rows inside a pivot table can’t be deleted or inserted one at a time. To delete the whole pivot table, select all of it first, as the questions below explain.

Pivot table exercises with answers

These 11 exercises run on one table. Exercises 1 to 7 use Excel’s menus to build and change pivot tables, and their answers say what you should see. Exercises 8 to 11 check the same numbers with formulas. Download the workbook to do them in Excel, or type the table in yourself, starting in cell A1.

Download the practice workbook

Excel file, 9 KB. It opens in Google Sheets too.

A gift shop’s orders for April and May, one to a row. Build each PivotTable on a new sheet, so the orders stay as they are. The formulas go in the yellow cells.

The table for exercises 1 to 11
ABCDEFGH
1DateChannelCategoryQtySales
22 Apr 2026ShopBooks336Books sales (your answer goes here)
35 Apr 2026OnlineGifts250Online orders (your answer goes here)
49 Apr 2026ShopCards624Online Books (your answer goes here)
513 Apr 2026OnlineBooks448Online share (your answer goes here)
618 Apr 2026ShopGifts125
722 Apr 2026OnlineCards936
827 Apr 2026ShopBooks224
91 May 2026OnlineGifts375
106 May 2026ShopCards520
1111 May 2026OnlineBooks672
1215 May 2026ShopGifts4100
1320 May 2026OnlineCards728
1426 May 2026OnlineBooks112
1529 May 2026OnlineGifts250
  1. Click a cell in the orders and insert a PivotTable on a new worksheet: on the Insert tab, choose PivotTable, then OK. Tick Category, then Sales. What does it show for each category, and what’s the grand total?
  2. Go back to the orders and type 48 over the 36 in E2. Then right-click the PivotTable and choose Refresh. What are the Books total and the grand total now?
  3. Drag Channel into the Columns box. How much did the Online channel sell in Books, and how much in all?
  4. Change the sums to counts: right-click a number in the PivotTable, choose Summarize Values By, then Count. How many orders came through each channel?
  5. Switch back to Sum with Summarize Values By. Then right-click a number, choose Show Values As, then % of Grand Total. What share of all sales came through the Online channel, and what share were Online Gifts?
  6. Set Show Values As back to No Calculation and untick Channel. Then sort the categories by sales, largest first: right-click a number, choose Sort, then Sort Largest to Smallest. What order are they in now?
  7. Insert a second PivotTable from the orders, on another new sheet, with Date in Rows and Sales in Values. If it lists every date, right-click one, choose Group, select Months and click OK. What did each month sell?
  8. In H2, add up the Books sales with SUMIFS, to check the PivotTable’s total.
  9. In H3, count the Online orders.
  10. In H4, add up the Online sales of Books.
  11. In H5, work out the Online share of all sales.

Answers to exercises 1 to 11

ExerciseFormulaHow it worksResult
1Insert tab: PivotTable, then tick Category and SalesCategory is text, so Excel puts it in Rows. Sales holds numbers, so it goes to Values and is added up for each category.Books 192, Cards 108 and Gifts 300, with a grand total of 600.
2Right-click the PivotTable: Refresh, or press Alt+F5A PivotTable keeps its numbers until it’s refreshed. Refresh reads the same range again, so a row added below the orders would still be left out.Books 204 and a grand total of 612. Until the refresh, the PivotTable showed the old totals. Type 36 back in E2 and refresh again before you go on.
3PivotTable Fields pane: drag Channel to ColumnsEach number now belongs to one category and one channel. Exercise 10 works out the first one with a formula.132 in Books, and 371 in all: the grand total at the foot of the Online column.
4Right-click a number: Summarize Values By, then CountCount of Sales counts the orders in each group, whatever they’re worth. Exercise 9 counts the Online orders with a formula.Online 8 and Shop 6: 14 orders in all.
5Right-click a number: Show Values As, then % of Grand TotalEach number is now its sales divided by the grand total, so the whole PivotTable adds up to 100%. Exercise 11 works out the Online share with a formula.61.8% came through Online, at the foot of its column. Online Gifts alone were 29.2%.
6Right-click a number: Sort, then Sort Largest to SmallestA PivotTable lists its items from A to Z until you sort it. To put them back, use the arrow on Row Labels and choose Sort A to Z.Gifts 300, then Books 192, then Cards 108.
7Right-click a date in the PivotTable: Group, then MonthsExcel 2016 and later group the dates by themselves when you add them. Every date here is in 2026, so Months is enough. For dates in more than one year, select Years too, or each month adds up the same month of every year.April 243 and May 357.
8=SUMIFS(E2:E15,C2:C15,"Books")SUMIFS adds the sales whose category is Books: 192, the number in the PivotTable’s Books row. Also works: =SUMIF(C2:C15,"Books",E2:E15).192
9=COUNTIFS(B2:B15,"Online")COUNTIFS counts the rows whose channel is Online, as Count of Sales does in the PivotTable. Also works: =COUNTIF(B2:B15,"Online").8
10=SUMIFS(E2:E15,B2:B15,"Online",C2:C15,"Books")Each extra pair of a range and a condition narrows the total down, as putting Channel in Columns does: 132.132
11=SUMIFS(E2:E15,B2:B15,"Online")/SUM(E2:E15)Online’s sales over the grand total, which % of Grand Total shows in the Online column. Format the cell as a percentage. Also works: =SUMIF(B2:B15,"Online",E2:E15)/SUM(E2:E15).61.8%

Questions

Do pivot tables update automatically?

No. A pivot table keeps its numbers until you refresh it: right-click it and choose Refresh, or press Alt+F5. To refresh it each time the file opens, go to PivotTable Analyze, then Options, and on the Data tab tick Refresh data when opening the file. Microsoft’s help page lists Auto Refresh, which updates a pivot table when data in the same workbook changes, for members of the Microsoft 365 Insider programme.

Why is my pivot table not showing new data?

Either it hasn’t been refreshed, or the new rows are outside the range it was built from. Refresh it first. If they still don’t show, choose Change Data Source on the PivotTable Analyze tab and select the whole range. Building the pivot table on a table, made with Ctrl+T, avoids this, because a table grows as you add rows.

How do I delete a pivot table?

Click it, then on the PivotTable Analyze tab choose Select, then Entire PivotTable, and press Delete. Pressing Ctrl+A inside the pivot table selects all of it too. If it has a sheet to itself, right-click the sheet tab and choose Delete instead. Selecting only part of it gives the message Cannot change this part of a PivotTable report.

Is it hard to learn pivot tables?

No. Building one takes the four steps above, and changing it means dragging fields between four boxes. What trips most people up is the data, which needs one row of headings and no gaps, and forgetting to refresh after it changes. The exercises above cover both, on a table small enough to check by hand.

What is replacing pivot tables?

Nothing has replaced them. Microsoft 365 added two functions, GROUPBY and PIVOTBY, that build a similar summary with a formula: =GROUPBY(B2:B13,F2:F13,SUM) gives the same totals by region as the first pivot table above, such as 1,709 for North. Pivot tables are in every version of Excel, and Microsoft is still adding to them, such as Auto Refresh.

What’s the keyboard shortcut for a pivot table?

On Windows, press Alt, then N, V and T, to start a pivot table from the data you’ve selected. Alt+F5 refreshes the pivot table you’re in, and Alt, then J, T and L, opens the PivotTable Fields pane.

How do I make a pivot table in Google Sheets?

Select the data, choose Insert, then Pivot table, pick New sheet and click Create. In the editor beside the pivot table, click Add next to Rows, Columns, Values or Filters and choose a field. Each column needs a heading, as in Excel. Unlike Excel’s, a Google Sheets pivot table updates by itself when its data changes.

Keep practising

Excel Foundations, our free course, teaches SUMIF, COUNTIF, AVERAGEIF and SUMIFS in its seventh module: the formulas that give the same numbers as a pivot table. It has 30 short lessons and 82 exercises in a live sheet, and passing its test earns a certificate of completion.

See what’s in Excel Foundations

Excel Intermediate builds summary tables with formulas in a module of its own: a grid of totals by two fields, a grid of counts and shares of a total. Excel Test Prep practises the tools that employers’ Excel tests ask about. Both come with Pro. For more practice, try our Excel exercises with answers, which include a PivotTable task, or our guide to finding duplicates, which counts unique values with UNIQUE.

Start with Excel Foundations. It’s free.

Pro is $19 a month or $99 a year for every other track, with SQL included as it launches.

Create free account Go to your lessons