Software & OS

How to Set Up a Pivot Table in Excel (Step by Step)

To set up a pivot table in Excel, click a cell in your data, choose Insert > PivotTable, pick a location and select OK. Then drag fields from the PivotTable Fields list into the Rows and Values areas to build the summary.

The menu names below follow Microsoft's documentation for Excel on Windows. Excel for the web and Excel on Mac can differ slightly, and the Excel version you have may change some labels.

Step 1: Get your data into a clean table layout

Most pivot table problems start with the source data, not the pivot table. Microsoft's guidance for source data is short:

  • Arrange the data in columns with a single header row.
  • Give every column a unique, non-blank header.
  • Avoid blank rows, blank columns, double header rows and merged cells.
  • Keep one data type in each column. Don't mix dates and text, or numbers and text.

Microsoft also recommends using an Excel table where possible, because rows and columns added to a table are picked up when you refresh the pivot table. If a date column shows text-style dates that won't sort or group, fix the format first, as described in how to change the date format in Excel.

The examples here use a small sales list with these column headers:

Date | Region | Product | Salesperson | Units | Revenue

Step 2: Insert the pivot table

  1. Select any cell inside the data, or select the whole range.
  2. Go to Insert > PivotTable.
  3. In the dialog, check that the table or range shown is the one you want. You can also tick Add this data to the Data Model, which you only need for multi-table analysis.
  4. Choose New Worksheet or Existing Worksheet for the report.
  5. Select OK.

Excel adds an empty pivot table and shows the PivotTable Fields list on the right. Nothing appears in the grid until you pick fields. A new worksheet is the safer choice for a first pivot table, because the report can grow and overwrite nearby cells on an existing sheet.

If you use the arrow on the PivotTable button instead, the other sources offered are Get from External Data Source, Get from Data Model and Get from Power BI.

The shortcut: Recommended PivotTable

Select a cell in the data and go to Insert > Recommended PivotTable. Choose a layout and select OK. Excel creates it on a new sheet with the field list open. Microsoft states this feature is available only to Microsoft 365 subscribers. Even if you use it, you still need the next steps to adjust the result.

Step 3: Drag fields into Rows, Columns and Values

The PivotTable Fields list shows one entry per column header. The layout areas are Rows, Columns and Values. When you tick a field, Excel places it by type:

Field typeDefault area
Non-numeric (text)Rows
Date and timeColumns
NumericValues

You can drag a field to a different area at any time. For the sample data, a first useful report is revenue by region:

  1. Drag Region into Rows.
  2. Drag Revenue into Values.

Example output (made-up numbers, for illustration only):

Row Labels    Sum of Revenue
East                  48,200
North                 31,750
West                  52,900
Grand Total          132,850

To split each region by product, drag Product into Columns. To nest a second level under each region in the rows, drag a second field into Rows below Region. The order of fields within an area sets the nesting order, so drag them up or down to swap levels.

Step 4: Change what the pivot table calculates

Numeric fields in Values default to SUM. If Excel reads the field as text, it uses COUNT instead. That is the usual reason a pivot table shows "Count of Revenue" when you expected a total: some cells in the column are text, not numbers.

To change the calculation on Windows:

  1. In the Values area, click the arrow next to the field name.
  2. Select Value Field Settings.
  3. Under Summarize Values By, choose the calculation you want, such as Average or Count.
  4. Select OK.

In Excel for the web, right-click a value in the pivot table and select Summarize Values By.

You can drag the same field into Values twice and give each copy a different calculation. That lets you show, for example, total units and average units side by side.

Step 5: Group dates or numbers

Raw dates produce one row per day, which is rarely what you want. To roll them up:

  1. Right-click a date value in the pivot table and select Group.
  2. In the Grouping box, use the Starting at and Ending at checkboxes if you want to limit the range.
  3. Under By, choose a time period. For a numeric field, enter the interval for each group instead, for example 100 to bucket revenue in steps of 100.
  4. Select OK.

Microsoft's page does not list the individual choices in the By box, so check the list in your version. To undo it, right-click any item in the group and select Ungroup. Grouping fails if the column contains text or blank cells where dates should be, which is another reason to clean the source first.

Step 6: Refresh the pivot table after the data changes

A pivot table is a snapshot. Editing the source cells does not change it until you refresh:

  • One pivot table: right-click inside it and select Refresh.
  • Every pivot table in the workbook: select a cell in a pivot table, go to PivotTable Analyze, open the arrow under Refresh and select Refresh All.

In Excel for the web, right-click in the pivot table range and select Refresh. On iPad, press and hold a cell in the pivot table and select Refresh. If the source is a plain range and you added rows below it, the pivot table may not include them. Converting the range to an Excel table in Step 1 prevents that.

Common problems

  • Numbers show as counts. The column holds text. Convert those cells to numbers in the source, then refresh.
  • Dates won't group. The date column contains text or blanks. Make every cell in the column a real date.
  • A blank row or column appears in the results. The source has empty cells in a field you are using. Fill them or remove the rows, then refresh.
  • Fields are missing or mislabeled. Check the header row. Microsoft's guidance is a unique, non-blank header on every column.

Frequently asked questions

Why is my pivot table counting instead of summing?
Excel defaults numeric fields to SUM, but if it reads the column as text it uses COUNT. Usually some cells in the column hold numbers stored as text, or the column mixes text and numbers. Fix the source cells so the whole column is numeric, refresh, or change the calculation under Value Field Settings > Summarize Values By.
Why doesn't my pivot table update when I change the data?
A pivot table does not recalculate when the source cells change. Right-click inside it and select Refresh. If you added rows below the source range and the data is not an Excel table, the range itself may need to be extended; converting the data to a table avoids that.
Can I make a pivot table from data with blank rows or merged cells?
It is better not to. Microsoft advises a single header row, a unique non-blank header for each column, and no blank rows, blank columns or merged cells in the source. Clean those up first, or the pivot table may pick the wrong range or group data incorrectly.
What is a Recommended PivotTable?
It is an Insert > Recommended PivotTable option that suggests ready-made layouts for your data. Microsoft's documentation says it is available only to Microsoft 365 subscribers, so it may be missing in older, non-subscription versions of Excel.

Sources