Microsoft Developer Network

Office Documentation

Mastering Pivot Tables in Microsoft Excel

A Step-by-Step Tutorial for Data Analysis and Reporting

Introduction to Pivot Tables

Pivot Tables are one of Excel's most powerful features for summarizing, analyzing, exploring, and presenting large amounts of data. They allow you to quickly transform complex datasets into meaningful insights without altering the original data.

This tutorial will guide you through the process of creating and customizing pivot tables, enabling you to slice and dice your data with ease.

Prerequisites

  • Microsoft Excel installed (any recent version will suffice).
  • A basic understanding of spreadsheets.
  • A dataset to work with (we'll use a sample dataset for demonstration).

For this tutorial, let's assume you have a dataset containing sales information, including columns like 'Product', 'Region', 'Salesperson', 'Date', and 'Revenue'.

Step 1: Prepare Your Data

1

Ensure your data is organized in a tabular format with clear headers. Each column should represent a specific type of information, and each row should represent a single record. Avoid blank rows or columns within your dataset.

Best Practice: Format your data as an Excel Table (Insert > Table) for easier management and dynamic updates.

Sample Excel Data Table

Step 2: Insert a Pivot Table

2

Select any cell within your data range or Excel Table.

Go to the Insert tab on the Excel ribbon.

Click the PivotTable button.

Excel Insert PivotTable Button

The "Create PivotTable" dialog box will appear.

  • Choose the data that you want to analyze: Excel will usually auto-select your table or range. Verify that it's correct.
  • Choose where you want the PivotTable report to be placed: Select "New Worksheet" to create the pivot table on a new sheet (recommended for clarity) or "Existing Worksheet" to place it on a sheet you select.

Click OK.

Step 3: Design Your Pivot Table Layout

3

A new worksheet will appear with a blank PivotTable placeholder on the left and the "PivotTable Fields" pane on the right. This pane lists all the headers from your source data.

Drag and drop the fields into the four areas at the bottom of the "PivotTable Fields" pane:

  • Rows: Fields placed here will appear as row labels. (e.g., 'Region')
  • Columns: Fields placed here will appear as column labels. (e.g., 'Product')
  • Values: Fields placed here are typically numerical and will be summarized (summed, counted, averaged, etc.). (e.g., 'Revenue')
  • Filters: Fields placed here allow you to filter the entire report. (e.g., 'Salesperson')

As you drag fields, the PivotTable will update in real-time.

Excel PivotTable Fields Pane

For our example, let's drag 'Region' to Rows, 'Product' to Columns, and 'Revenue' to Values.

Step 4: Customize Value Field Settings

4

By default, Excel sums numerical data. You can change this to count, average, find the maximum, minimum, etc.

In the "PivotTable Fields" pane, click the dropdown arrow next to the field in the Values area (e.g., 'Sum of Revenue').

Select Value Field Settings....

In the dialog box, choose the desired calculation type (e.g., Average, Count).

You can also change the Custom Name for the field.

Excel Value Field Settings

Click OK.

Step 5: Formatting and Refining Your Pivot Table

5

Sorting and Filtering: Use the dropdown arrows on the row and column labels in your PivotTable to sort data or filter specific items.

Slicers and Timelines: For interactive filtering, go to the PivotTable Analyze tab (appears when the PivotTable is selected) and click Insert Slicer or Insert Timeline (for date fields).

Changing Layout: Use the Design tab to change the report layout (Compact, Outline, Tabular) and apply various styles.

Grand Totals and Subtotals: Control whether subtotals and grand totals are displayed from the Design tab.

Refreshing Data: If your source data changes, right-click anywhere in the PivotTable and select Refresh to update the report.

Advanced Techniques (Briefly)

  • Calculated Fields and Items: Create custom formulas within your pivot table.
  • Grouping: Group dates by month/year, or numbers into ranges.
  • PivotCharts: Create dynamic charts directly from your pivot table data.