Excel Pivot Tables - Quick Guide

Excel Pivot Tables - Overview

A PivotTable is an extremely powerful tool that you can use to slice and dice data. You can track and analyze hundreds of thousands of data points with a compact table that can be changed dynamically to enable you to find the different perspectives of the data. It is a simple tool to use, yet powerful.

The major features of a PivotTable are as follows −

In this tutorial, you will understand these PivotTable features in detail along with examples. By the time you complete this tutorial, you will have sufficient knowledge on PivotTable features that can get you started with exploring, analyzing, and reporting data based on the requirements.

Creating a PivotTable

You can create a PivotTable from a range of data or an Excel table. You can start with an empty PivotTable to fill in the details, if you are aware of what you are looking for. You can also make use of Excel Recommended PivotTables that can give you heads up on the PivotTable layouts that are best suited for summarizing your data.

You will learn how to create a PivotTable from a data range or Excel table in the Chapter - Creating a PivotTable from a Table or Range.

Excel gives you a more powerful way of creating a PivotTable from multiple tables, different data sources, and external data sources. It is named as PowerPivot that works on its database known as Data Model. You will learn these Excel power tools in other tutorials in this Tutorials Library.

You need to first know about the normal PivotTable as explained in this tutorial, before you venture into the power tools.

PivotTable Layout - Fields and Areas

The PivotTable layout simply depends on what fields you have selected for the report and how you have arranged them in Areas. The selection and arrangement can be done by just dragging the fields. As you drag the fields, the PivotTable layout keeps the changing and it happens in a matter of seconds.

You will learn about PivotTable Fields and Areas in the Chapters – PivotTable Fields and PivotTable Areas.

Exploring Data with PivotTable

The primary goal of using a PivotTable normally is to explore the data to extract significant and required information. You have several options to do this that include Sorting, Filtering, Nesting, Collapsing and Expanding, Grouping and Ungrouping, etc.

You will have an overview of these options in the Chapter - Exploring Data with PivotTable.

Summarizing Values

Once you collate the data required by you by the different exploration techniques, the next step that you would like to take is to summarize the data. Excel provides you with a variety of calculation types that you can apply based on suitability and requirement. You can also switch across different calculation types and view the results in a matter of seconds.

You will learn how to apply the calculation types on a PivotTable in the Chapter - Summarizing Values by Different Calculation Types.

Updating a PivotTable

Once you have explored the data and summarized it, you need not repeat the exercise if and when the source data gets updated. You can refresh the PivotTable so that it reflects the changes in the source data.

You will learn the various ways of refreshing data in the Chapter – Updating a PivotTable.

PivotTable Reports

After exploring and summarizing the data with a PivotTable, you would be presenting it as a report. PivotTable reports are interactive in nature, with the specialty that even a person not familiar with Excel can use them intuitively. Because of their inherent dynamic nature, they will enable you to change the perspective quickly of the report to show the required level of detail or to focus on the specific items in which the audience expresses interest.

Further, you can structure a PivotTable report for standalone presentation or as an integral part of a broad report as the case may be. You will learn the several of reporting with PivotTables in the Chapter – PivotTable Reports.

Excel Pivot Tables - Creation

You can create a PivotTable either from a range of data or from an Excel table. In both the cases, the first row of the data should contain the headers for the columns.

If you are sure of the fields to be included in the PivotTable and the layout you want to have, you can start with an empty PivotTable and construct the PivotTable.

In case you are not sure which PivotTable layout is best suitable for your data, you can make use of Recommended PivotTables command of Excel to view the PivotTables customized to your data and choose the one you like.

Creating a PivotTable from a Data Range

Consider the following data range that contains the sales data for each Salesperson, in each Region and in the months of January, February and March −

Creating PivotTable

To create a PivotTable from this data range, do the following −

Click PivotTable in the Tables group. The Create PivotTable dialog box appears.

Tables Group

In Create PivotTable dialog box, under Choose the data that you want to analyze, you can either select a Table or Range from the current workbook or use an external data source.

As you are creating a PivotTable from a data range, select the following from the dialog box −

You can choose to analyze multiple tables, by adding this data range to Data Model. You can learn how to analyze multiple tables, use of Data Model and how to use an external data source to create a PivotTable in the tutorial Excel PowerPivot.

Range Name

A new worksheet is inserted into your workbook. The new worksheet contains an empty PivotTable. Name the worksheet – Range-PivotTable.

Range PivotTable

As you can observe, the PivotTable Fields list appears on the right side of the worksheet, containing the header names of the columns in the data range. Further, on the Ribbon, PivotTable Tools – ANALYZE and DESIGN appear.

Adding Fields to the PivotTable

You will understand in detail about PivotTable Fields and Areas in the later chapters in this tutorial. For now, observe the steps to add fields to the PivotTable.

Suppose you want to summarize the order amount salesperson-wise for the months January, February, and March. You can do it in few simple steps as follows −

Your first PivotTable is ready as shown below

First PivotTable

Observe that two columns appear in the PivotTable, one containing the Row Labels that you selected, i.e. Salesperson and Month and a second one containing Sum of Order Amount. In addition to Sum of Order Amount month wise for each Salesperson, you will also get subtotals representing the total sales by that person. If you scroll down the worksheet, you will find the last row as Grand Total representing total sales.

You will learn more about producing PivotTables as per the need as you progress through this tutorial.

Creating a PivotTable from a Table

Consider the following Excel table that contains the same sales data as in the previous section −

Excel Table

An Excel table will inherently have a name and the columns will have headers, which is a requirement to create a PivotTable. Suppose the table name is SalesData_Table.

To create a PivotTable from this Excel table, do the following −

Insert Tab Sales Data Table

A new worksheet is inserted into your workbook. The new worksheet contains an empty PivotTable. Name the worksheet – Table-PivotTable. The worksheet – Table-PivotTable looks similar to the one you have got in the data range case in the earlier section.

You can add fields to the PivotTable as you have seen in the section – Adding Fields to the PivotTable, earlier in this chapter.

Creating a PivotTable with Recommended PivotTables

In case you are not familiar with Excel PivotTables or if you do not know which fields would result in a meaningful report, you can use the Recommended PivotTables command in Excel. Recommended PivotTables gives you all the possible reports with your data along with the associated layout. In other words, the options displayed will be the PivotTables that are customized to your data.

To create a PivotTable from the Excel table SalesData-Table using Recommended PivotTables, proceed as follows −

Recommended PivotTables

In the Recommended PivotTables dialog box, the possible customized PivotTables that suit your data will be displayed.

You will be get the preview on the right side.

Preview

The selected PivotTable appears on a new worksheet in your workbook.

Select PivotTable

You can see that the PivotTable Fields - Salesperson, Region, Order Amount and Month got selected. Of these, Region and Salesperson are in ROWS area, Month is in COLUMNS area, and Sum of Order Amount is in ∑ VALUES area.

The PivotTable summarized the data Region-wise, Salesperson-wise and Month-wise. The subtotals are displayed for each Region, each Salesperson, and each Month.

Excel Pivot Tables - Fields

PivotTable Fields is a Task Pane associated with a PivotTable. The PivotTable Fields Task Pane comprises of Fields and Areas. By default, the Task Pane appears at the right side of the window with Fields displayed above Areas.

Fields represent the columns in your data – range or Excel table, and will have check boxes. The selected fields are displayed in the report. Areas represent the layout of the report and the calculations included in the report.

At the bottom of the Task Pane, you will find an option – Defer Layout Update with an UPDATE button next to it.

Update

In this chapter, you will understand the details about Fields. In the next chapter, you will understand the details about Areas.

PivotTable Fields Task Pane

You can find the PivotTable Fields Task Pane on the worksheet where you have a PivotTable. To view the PivotTable Fields Task Pane, click the PivotTable. In case the PivotTable Fields Task Pane is not displayed, check the Ribbon for the following −

The PivotTable Fields Task Pane will be displayed on the right side of the window, with the title – PivotTable Fields.

PivotTables Task Pane

Moving PivotTable Fields Task Pane

On the right of the title PivotTable Fields of the PivotTable Task Pane, you will find the button Down Arrow. This represents Task Pane Options. Click the button Down Arrow. The Task Pane Options- Move, Size and Close appear in the dropdown list.

Moving PivotTables Task Pane

You can move the PivotTables Task Pane to anywhere you want in the window as follows −

Labels

You can place the Task Pane on the left side of the window as given below.

Taskpane

Resizing PivotTable Fields Task Pane

You can resize the PivotTables Task Pane – i.e. increase / decrease the Task Pane length and/or width as follows −

In the ∑ VALUES area, to make Sum of Order Amount visible completely, you can resize the Task Pane as given below.

Resizing

PivotTable Fields

The PivotTable Fields list comprises of all the tables that are associated with your workbook and the corresponding fields. It is by selecting the fields in the PivotTable fields list, you will create the PivotTable.

The tables and the corresponding fields with check boxes, reflect your PivotTable data. As you can check / uncheck the fields randomly, you can quickly change the PivotTable, highlighting the summarized data that you want to report or present.

PivotTable Fields

As you can observe, if there is only one table, the table name will not be displayed in the PivotTable Fields list. Only the fields will be displayed with check boxes.

Above the fields list, you will find the action Choose fields to add to report. To the right, you will find the button − Settings that represents Tools.

In the dropdown list, you will find the following −

Tools

As you can observe in the above Fields list, the Sort order is by default – i.e. in Data Source Order. This means, it is the order in which the columns in your data table appear.

Normally, you can retain the default order. However, at times, you might encounter many fields in a table and might not be acquainted with them. In such a case, you can sort the fields in alphabetical order by clicking on – Sort A to Z in the dropdown list of Tools. Then, the PivotTable Fields list looks as follows −

Data Source Order

Excel Pivot Tables - Areas

PivotTable areas are a part of PivotTable Fields Task Pane. By arranging the selected fields in the areas, you can arrive at different PivotTable layouts. As you can simply drag the fields across areas, you can quickly switch across the different layouts, summarizing the data, in a way you want.

You have already learnt about PivotTable Fields Task Pane in the earlier chapter on PivotTable Fields in this tutorial. In this chapter, you will learn about the PivotTable areas.

There are four PivotTable areas available −

PivotTable Areas

The message - Drag fields between areas below appears above the areas.

With PivotTable Areas, you can choose −

You can just drag the fields across these areas and observe how the PivotTable Layout changes.

ROWS

If you select the fields in the PivotTable Fields lists by just checking the boxes, all the nonnumeric fields will automatically be added to the ROWS area, in the order you select.

You can optionally, drag a field to the ROWS area. The fields that are put in ROWS area appear as rows in the PivotTable, with the Row Labels being the values of the selected fields.

For example, consider the Sales data table.

Your PivotTable appears with one column containing the Row Labels – Salesperson and Month and a last row as Grand Total, as given below.

Rows

COLUMNS

You can drag fields to the COLUMNS area.

The fields that are put in COLUMNS area appear as columns in the PivotTable, with the Column Labels being the values of the selected fields.

Drag the field Region to COLUMNS area. Your PivotTable appears with the first column containing the Row Labels – Salesperson and Month the next four columns containing the Column Labels – Region and a last column Grand Total as given below.

Column Columns Row

You can see that there are only five columns now – the first column with Row Labels, three columns with Column Labels and a last column with Grand Total.

The number of Rows and Columns is based on the number of values you have in those fields.

∑ VALUES

The primary use of a PivotTable is to summarize values. Hence, by placing the fields by which you want to summarize the data in ∑ VALUES area, you arrive at the summary table.

Sigma Values

As you can observe, the data is summarized region-wise, salesperson-wise and monthwise. You have subtotals for each region, month wise. You also have grand totals month wise in the Grand Total row grand totals region wise in the Grand Total column.

FILTERS

The Filters area is to place filters in PivotTable. Suppose you want to display results separately for the selected regions only.

Drag the field Region from ROWS area to FILTERS area. The filter Region will be placed above the PivotTable. In case you do not have empty rows above the PivotTable, the PivotTable is pushed down inserting rows above the PivotTable for the filter.

Filters

As you can observe, (ALL) appears in the filter by default, and the PivotTable displays data for all the values of the Region.

All

Check boxes will appear for all the options in the dropdown list. By default, all the boxes are checked.

Check Boxes

The PivotTable gets changed to reflect the filtered data.

Reflect

You can observe that the filter displays (Multiple Items). Therefore, when someone is looking at the PivotTable, it is not immediately obvious of what values are filtered.

Excel provides you another tool called Slicers to handle filtering more efficiently. You will understand Filtering Data in a PivotTable in detail in a later chapter in this tutorial.

 

Excel Pivot Tables - Exploring Data

Excel PivotTable allows you to explore and extract significant data from an Excel table or a range of data. There are several ways of doing this and you can choose the ones that are best suited to your data. Further, while you are exploring the data, you can view the different combinations instantly as you change your choices to pick the data values.

You can do the following with a PivotTable −

Sorting and Filtering Data

You can sort the data in a PivotTable in ascending or descending order of the field values. You can also sort by subtotals from largest to smallest or smallest to largest values. You can also set sort options. You will learn these in detail in the chapter – Sorting Data in a PivotTable in this tutorial.

You can filter the data in a PivotTable to focus on some specific data. You have several filtering options in PivotTable that you will learn in the chapter – Filtering Data in a PivotTable in this tutorial. You can use Slicers for filtering, which you will learn in the chapter – Filtering using Slicers in this tutorial.

Nesting, Expanding and Collapsing Fields

You can nest fields in a PivotTable to show a hierarchy, if relevant to your data. You will learn this in the chapter - Nesting in a PivotTable in this tutorial.

When you have nested fields in your PivotTable, you can expand and collapse the values of those fields. You will learn these in the Chapter – Exploring Data with PivotTable Tools in this tutorial.

Grouping and Ungrouping Field Values

You can group and ungroup specific values of a field in a PivotTable. You will learn this in the Chapter – Exploring Data with PivotTable Tools in this tutorial

Excel Pivot Tables - Sorting Data

You can sort the data in a PivotTable so that it will be easy for you to find the items you want to analyze. You can sort the data from lowest to highest values or highest to lowest values or in any other custom order that you choose.

Consider the following PivotTable wherein you have the summarized sales data region-wise, salesperson-wise and month-wise.

Sum of Order Amount

Sorting on Fields

You can sort the data in the above PivotTable on Fields that are in Rows or Columns – Region, Salesperson and Month.

To sort the PivotTable with the field Salesperson, proceed as follows −

Sorting

The following sorting options are displayed −

Further, the Salesperson field is sorted in ascending order, by default. Click Sort Z to A. The Salesperson field will be sorted in descending order.

Sort Z to A

In the same way, you can sort the field in column – Month, by clicking on the arrow Down Arrow in the column labels.

Sorting on Subtotals

Suppose you want to sort the PivotTable based on total order amount – highest to lowest in every Region. That is, you want to sort the PivotTable on subtotals.

Sorting on Subtotals

You can see that there is no arrow Down Arrow for subtotals. You can still sort the PivotTable on subtotals as follows −

Grand Total

The subtotals in the Grand Total column are sorted from highest to lowest values, in every region.

Click Sort

Likewise, if you want to sort the PivotTable on subtotals region wise, do the following −

Total Amount

As you can observe, South has the highest order amount while North has the lowest.

You can also sort the PivotTable based on the total amount month wise as follows −

The PivotTable will be sorted on total amount month wise.

More Sort Options

You can observe that February has highest order amount while March has the lowest.

More Sort Options

Suppose you want to sort the PivotTable on total amount region wise in the month of January.

Region

As you can observe, under Summary, the current Sort order is given as Sort Region in ascending order. Ascending (A to Z) by is selected under Sort Options. In the box below that, Region is displayed.

More Options

Click the More Options button. The More Sort Options (Region) dialog box appears.

Values in selected Column

As you can observe, under Sort By, Grand Total is selected. Under Summary, the current sort order is given as Sort Region by Sum of Order Amount in ascending order.

Ascending Order

As you can observe, under Summary, the current sort order is given as follows −

Under Summary

Under Summary, the current sort order is given as follows −

Sort Region by Sum of Order Amount in descending order, using values in this column: January. Click OK. The PivotTable will be sorted on region, using values in January.

Sorting Data Manually

As you can observe, in the month of January, West has the highest order amount while North has the lowest.

Sorting Data Manually

In the PivotTable, the data is sorted automatically by the sorting option that you have chosen. This is termed as AutoSort.

Place the cursor on the arrow Down Arrow in Row Labels or Column Labels.

Select Manual

AutoSort appears, showing the current sort order for each of the fields in the PivotTable. Now, suppose you want to sort the field Region in the order – East, West, North and South. You can do this manually, as follows −

Select Region

Under Summary, the current sort order is given as Drag items of the Region field to display them in any order.

Click on the East and drag it to the top. While you are dragging East, a horizontal green bar appears across the entire row moves.

Click on East

Repeat the dragging with other items of the Region field until you get the required arrangement.

Repeat

You can observe the following −

Note − You cannot use this manual dragging of items of the field that is in ∑ VALUES area of the PivotTable Fields list. Therefore, you cannot drag the Sum of Order Amount values in this PivotTable.

Setting Sort Options

In the previous section, you have learnt how to set the sorting option for a field to manual. You have some more sort options that you can set as follows −

More Sort Options (Region) dialog box appears. You can set more sort options in this dialog box.

Click OK

Under AutoSort, you can check or uncheck the box - Sort automatically every time the report is updated, to allow or stop automatic sorting whenever the PivotTable data is updated.

Now, First key sort order option becomes available. You can use this option to select the custom order you want to use.

Click the Box

As you can observe, day-of-the-week and month-of-the year custom lists are provided in the dropdown list. You can use any of these, or you can use your own custom list such as High, Medium, Low or the sizes list S, M, L, XL that are not in alphabetical order.

You can create your custom lists from the FILE tab on the Ribbon. FILE → Options. In the Excel Options dialog box, click on advanced and browse to General. You will find the Edit Custom Lists button next to Create lists for use in sort and fill sequences.

Advanced

Note that a custom list sort order is not retained when you update (refresh) data in your PivotTable.

Under Sort By, you can click Grand Total or Values in selected columns to sort by these values. This option is not available when you set sorting to Manual.

Points to consider while sorting PivotTables

When you sort data in a PivotTable, remember the following −

Excel Pivot Tables - Filtering Data

You might have to do in-depth analysis on a subset of your PivotTable data. This might be because you have large data and your focus is required on a smaller portion of the data or irrespective of the size of the data, your focus is required on certain specific data. You can filter the data in the PivotTable based on a subset of the values of one or more fields. There are several ways to do that as follows −

You will learn filtering data using Slicers in the next chapter. You will understand filtering by the other methods mentioned above in this chapter.

Consider the following PivotTable wherein you have the summarized sales data region wise, salesperson wise and month wise.

Slicers

Report Filters

You can assign a Filter to one of the fields so that you can dynamically change the PivotTable based on the values of that field.

Drag Region from Rows to Filters in the PivotTable Areas.

Report Filters

The Filter with the label as Region appears above the PivotTable (in case you do not have empty rows above your PivotTable, PivotTable gets pushed down to make space for the Filter.

Space Filter

You will observe that

A drop-down list with the values of the field Region appears. Check the box Select Multiple Items.

Select Multiple Items

By default, all the boxes are checked. Uncheck the box (All). All the boxes will be unchecked.

Then check the boxes - South and West and click OK.

Uncheck Box

The data pertaining to South and West regions only will get summarized.

Data Pertaining

In the cell next to the Filter Region - (Multiple Items) is displayed, indicating that you have selected more than one item. However, how many items and / or which items is not known from the report that is displayed. In such a case, using Slicers is a better option for filtering.

Manual Filtering

You can also filter the PivotTable by picking the values of a field manually. You can do this by clicking on the arrow Down Arrow in the Row Labels or Column Labels cell.

Manual Filtering

Suppose you want to analyze only February data. You need to filter the values by the field Month. As you can observe, Month is part of Column Labels.

Click on the arrow Down Arrow in the Column Labels cell.

As you can observe, there is a Search box in the dropdown list and below the box, you have the list of the values of the selected field, i.e. Month. The boxes of all the values are checked, showing that all the values of that field are selected.

Search Box Check Box

The PivotTable displays only those values that are related to the selected Month field value – February. You can observe that the filtering arrow changes to the icon Filter Search to indicate that a filter is applied. Place the cursor on the Filter Search icon.

Month Field Value

You can observe that is displayed indicating that the Manual Filter is applied on the field- Month.

If you want to change the filter selection value, do the following −

If all the values of the field are not visible in the list, drag the handle in the bottom-right corner of the dropdown to enlarge it. Alternatively, if you know the value, type it in the Search box.

Suppose you want to apply another filter on the above filtered PivotTable. For example, you want to display the data of that of Walters, Chris for the month February. You need to refine your filtering by adding another filter for the field Salesperson. As you can observe, Salesperson is part of Row Labels.

Row Labels Cell

The list of the values of the field – Region is displayed. This is because, Region is at outer level of Salesperson in the nesting order. You also have an additional option – Select Field. Click on the Select Field box.

Check Walters

The PivotTable displays only those values that are related to the selected Month field value – February and Salesperson field value - Walters, Chris.

The filtering arrow for Row Labels also changes to the icon Filter Search to indicate that a filter is applied. Place the cursor on the Filter Search icon on either Row Labels or Column Labels.

Column Labels

A text box is displayed indicating that the Manual Filter is applied on the fields – Month, and Salesperson.

You can thus filter the PivotTable manually based on any number of fields and on any number of values.

Filtering by Text

If you have fields that contain text, you can filter the PivotTable by Text, provided the corresponding field label is text-based. For example, consider the following Employee data.

Employee Data

The data has the details of the employees – EmployeeID, Title, BirthDate, MaritalStatus, Gender and HireDate. Additionally, the data also has the manager level of the employee (levels 0 – 4).

Suppose you have to do some analysis on the number of employees reporting to a given employee by title. You can create a PivotTable as given below.

HireDate

You might want to know how many employees with ‘Manager’ in their title have employees reporting to them. As the Label Title is text-based, you can apply the Label Filter on the Title field as follows −

Manager

Label Filter (Title) dialog box appears. Type Manager in the box next to Contains. Click OK.

Title

The PivotTable will be filtered to the Title values containing ‘Manager’.

You can see that Filter Button is displayed indicating the following −

Applied Label Filter

Filtering by Values

You might want to know the titles of the employees who have more than 25 employees reporting to them. For this, you can apply the Value Filter on the Title field as follows −

Select Greater

The Value Filter (Title) dialog box appears. Type 25 in the right side box.

The PivotTable will be filtered to display the employee titles who have more than 25 employees reporting to them.

Employee Titles

Filtering by Dates

You might want to display the data of all the employees who were hired in the fiscal year 2015-15. You can use Data Filters for the same as follows −

ManagerLevel

Now that you have a Date field in the PivotTable, you can use Date Filters.

Select Between

The Date Filter (HireDate) dialog box appears. Type 4/1/2014 and 3/31/2015 in the two Date boxes. Click OK.

Data Filter

The PivotTable will be filtered to display only the data with HireDate between 1st April 2014 and 31st March 2015.

Display

You can group the dates into Quarters as follows −

By

The dates will be grouped into quarters in the PivotTable. You can make the table look compact by dragging the field HireDate from ROWS area to COLUMNS area.

You will be able to know how many employees were hired during the fiscal year, quarter wise.

Fiscal year

Filtering Using Top 10 Filter

You can use the Top 10 Filter to display the top few or bottom few values of a field in the PivotTable.

Top Filter

Top 10 Filter (Title) dialog box appears.

Field Count

The top seven values by count of EmployeeID will be displayed in the PivotTable.

Seven Values

As you can observe, the highest number of hires in the fiscal year is that of Production Technicians and a predominant number of these are in Qtr1.

Filtering Using Timeline

If your PivotTable has a date field, you can filter the PivotTable using Timeline.

Create a PivotTable from the Employee Data that you used earlier and add the data to the Data Model in the Create PivotTable dialog box.

EmployeeID Insert Timelines Timeline Appears

As you can observe, All Periods – in Months are displayed on the Timeline.

Select QUARTERS Q1

Clearing the Filters

You might have to clear the filters you have set from time to time to switch across different combinations and projections of your data. You can do this in several ways as follows −

Clearing all the filters in a PivotTable

You can clear all the filters set in a PivotTable at one go as follows −

Clearing Filters

Clearing a Label, Date or Value Filter

To clear a Label, Date, or Value Filter do the following −

Select Field Box