Skip to main content

Pivot Tables and how to use them


Excel pivot tables are very useful and powerful feature of MS Excel. They are be used to create instant summaries, reports and data analysis from your raw data

In this page, learn all about how to create an Excel pivot table and customize it.


1. What are Excel Pivot Tables 


A pivot table turns your data into report format. Here is a sample Pivot table from sales data, showing total sales by region.

Example of an Excel Pivot Table

2. How to Create a Pivot Table

We will use 2019 sales data of a fictional company. This data contains 466 rows of sales information in columns – Month, Salesman, Region, Product, No.  Customers, Net Sales, Profit / Loss. Here is a preview of our data.

Sample data - Pivot tables in Excel

To create a pivot table showing totals sales by region, follow these steps.

  1. Select any cell in the data.
  2. Go to Insert ribbon and click “Pivot Table” button.
    Insert Pivot Table button - Excel ribbon
  3.  Click ok on the next screen.
    Create Pivot Table dialog
  4. You will be taken a new spreadsheet with blank Pivot Table canvas.  Here, using the Pivot Table Fields panel set “Regions” field to row label area, “Products” to “Filter” area and “Net Sales” to values area. See below illustration.
    how to use pivot table fields - setting up a pivot table

Your pivot table will be ready. We can see that “West” is our best region. This is why Pivot tables are easy for finding answers to common business questions.


3. Two Dimensional Pivots

You can add fields to both “Row” and “Column” label area of a pivot. Such Pivot Tables are normally called two dimensional pivots. Here is a demo of a two dimensional pivot table showing Total Sales by Region & Sales Person.

Two dimensional pivot - demo


4. Multi dimensional Pivots

You can also add more than one item to “Row” or “Column” label area. This creates a multi-dimensional Pivot Report. Here is one such pivot report showing total sales by Region, Sales Person & Product for selected months.

Example Pivot Report - A very detailed Pivot Table with sub-totals and totals

 5. How to format Pivot table values

By default, numbers in Pivot Tables tend to just look like zip codes, without any proper formatting. This is easy to fix though. Simply right click on the values and use “Value Field Settings” to set up the formatting. To set currency formatting for our Total sales by region Pivot Report, 

  1. Go to value field settings
  2. Click on Number Format button
  3. Set up the formatting to “Currency”
  4. Done.

See this illustration.

How to currency format pivot table values

 

Sorting in Excel Pivot Tables

You can easily sort pivot report by ascending or descending order of the value. To do this, just right click on the value, select Sort > and specify the order.

Here is an example of sorted pivot report of Number of customers by Sales person.

Sorting a pivot table in descending order of sales

Filtering Excel Pivot Tables

You are looking at Regional total sales and want to know what the total is for just “RapidZoo” product. You can do this by filtering the pivot table. Excel offers two powerful ways to filter Pivot Tables

  1. Report filters
  2. Slicers

Both methods are illustrated below. Read on to learn how to use them.

Filtering an excel pivot table - two methods

Filtering with Report Filters

Report filter is a great way to restrict the data that is flowing to your pivot. To set them up, just add the field to “Filters” area in the fields panel. Now, using the filter button next to “Product”, select the product you want.

Here is a quick demo of report filters in action.

Report filter demo

Filtering with Slicers

There are a ton of cool features in Excel Pivot Tables, but slicers are hands-down the best feature. At-least, that is what I think. They make filtering and ad-hoc data analysis a breeze.

A slicer is a visual filter. You can add a slicer on any field by right clicking on it from the fields panel. See the illustration “Adding filters to a pivot report” from above. 

Once you have a slicer on Product, simply click on any product name to see the report for that. 

Here is a quick demo of Pivot Table with slicers.

Filtering a pivot table with slicer - demo

Other kinds of filtering - Value & Label Filters

Apart from report filters & Slicers, Pivot Tables also allow you to filter by a field or value. 

Field or Label Filter: If you don’t want to see “Middle” region in a row label area, just click on the filter button next to “Row Labels” and uncheck the region. This type of filtering is called Label Filtering.

Value Filter: If you want to see just the top 2 regions by total sales, then you need a value filter. Simply go to filter button next to row labels and using value filters, apply a top 10 filter but set it to top 2 values by “Sum of net sales.”

Changing Calculations in Pivot Tables

The default calculation in Pivot Tables is SUM for number fields and COUNT for all others. But you can also customize the calculation easily. Just right click on the value field and choose different type of summary from right click menu.

Changing from SUM to AVERAGE in a Pivot Table

Here is a quick illustration of how to change calculation type from “SUM” to “AVERAGE”.

how to change pivot table calculations

Pivot Table Layouts & Colors

By default, Excel Pivot Tables are in compact layout. This means, if you add multiple fields to row label area, they will all be shown in same column, with indentation.

You can change the layout of a pivot table to other formats too. 

  • Compact form (default)
  • Outline form
  • Tabular form

You can change the layout from Pivot Table Design ribbon.

Pivot Table layout options

Here is an example of same Pivot Table in both Compact and Tabular layouts. 

Compact vs. Tabular Layouts for Pivot Tables in Excel

Styling & colors of Excel Pivot Tables

You can apply any formatting to the pivot tables. MS Excel has some very good pivot table styles. Just select pivot table cells, go to Pivot Table Design ribbon. See below image to understand various options available.

Pivot table design options

Visualizing with Pivot Charts

You can use Pivot Charts to visualize the same information in a graphic format. Here is a sample Pivot Chart of Net Sales by Region & Product.

Excel Pivot Chart - Example

Steps for creating a Pivot Chart:

  1. Select any cell in the Pivot Table.
  2. Click on Insert > Chart or Analyze > Pivot Chart button.
  3. Insert the type of chart you want.
  4. You will get a Pivot Chart.

Interactive Pivot Chart with Slicers

Slicers make it incredibly easy to create interactive charts. Once you have a regular Pivot Chart, simply add a slicer to it (right click on the field in “Pivot Table Fields” area and select “Add as Slicer”). You now have an interactive Pivot Chart.

Here is a demo of interactive Pivot Chart. 

interactive pivot chart with slicers

Updating Pivot Tables (Refresh)

Whenever you have new data, just use “Refresh” button to update your Pivot Tables. You can find this button in multiple places.

  • Data ribbon
  • Pivot Table Analyze ribbon
  • On right clicking any Pivot Table
  • By pressing ALT+F5 (refreshes single pivot) or CTRL+ALT+F5 (refreshes all pivots)

Refresh and change data source options - Excel Pivot Table Analyze ribbonWhat if you want to point Pivot to new data?

Select any cell in the Pivot Table and from Analyze ribbon, use the “Change Data Source” button. Point input data to a new source. As long as the new data has same fields, everything will work smoothly.

Comments

Popular posts from this blog

Charts - Make your data presentable

One-click charts are easy: Select the data and press  Alt+F1 . What if you would rather create bar charts instead of the default clustered column chart? To make your life easier, you can change the default chart type. Store your favorite chart settings in a template and then teach Excel to produce your favorite chart in response to  Alt+F1 . Say that you want to clean up the chart above. All of those zeros on the left axis take up a lot of space without adding value. Double-click those numbers and change Display Units from None to Millions. To move the legend to the top, click the + sign next to the chart, choose the arrow to the right of Legend, and choose Top. Change the color scheme to something that works with your company colors. Right-click the chart and choose Save As Template. Then, give the template a name. (I called mine ClusteredColumn.) Select a chart. In the Design tab of the Ribbon, choose Change Chart Type. Click on the Templates folder to see the template that ...

Data Analysis Tool Pack

  The  Analysis ToolPak  is an  Excel add-in  program that provides data analysis tools for financial, statistical and engineering data analysis. To load the Analysis ToolPak add-in, execute the following steps. 1. On the File tab, click Options. 2. Under Add-ins, select Analysis ToolPak and click on the Go button. 3. Check Analysis ToolPak and click on OK. 4. On the Data tab, in the Analysis group, you can now click on  Data Analysis . The following dialog box below appears. 5. For example, select Histogram and click OK to create a Histogram in Excel. Example Rank and Percentile The Rank and Percentile contained within the Analysis-ToolPak can be quickly used to find the rank of all the values in a list. The advantage of using the Rank and Percentile feature is that the percentile is also added to the output table. The percentile is a percentage that indicates the proportion of the list which is below a given number. Highlight the list (or the cells) which...

20 Power BI Dax Measures

Power bi 20 dax measures 20 DAX (Data Analysis Expressions) measures in Power BI with examples: Total Sales: scss Copy code Total Sales = SUM (Sales[Amount]) Average Sales Price: scss Copy code Avg Sales Price = AVERAGE (Sales[Amount]) Total Units Sold: mathematica Copy code Total Units Sold = SUM ( Sales [ Quantity ] ) Total Customers: scss Copy code Total Customers = COUNTROWS (Customer) Total Products: mathematica Copy code Total Products = COUNTROWS ( Product ) Maximum Sales Amount: scss Copy code Max Sales Amount = MAX (Sales[Amount]) Minimum Sales Amount: scss Copy code Min Sales Amount = MIN (Sales[Amount]) Sales Growth Percentage: mathematica Copy code Sales Growth % = ( Total Sales - [ Total Sales Last Year ] ) / [ Total Sales Last Year ] Total Profit: scss Copy code Total Profit = SUM (Sales[Profit]) Total Orders: scss Copy code Total Orders = COUNTROWS (Orders) Total Customers with Sales: css Copy code Total Customers with Sales = COUNTROWS( FILTER ...