Calculate Differences in a Pivot Table

Calculate Differences in a Pivot Table

A pivot table is a great way to summarize data, and most of the time you probably use a Sum or Count function for the values. For example, in the pivot table shown below, the regional sales are totaled for each week. We can also use a built-in feature to calculate differences in a pivot table.

differencefrom01

Add Custom Calculations

Instead of settling for a basic sum or count, you can get fancier results by using the built-in Custom Calculations.

  • Right-click on a value cell in a pivot table
  • Then click Show Values As, to see a list of the custom calculations that you can use. This list is from Excel 2010, and there is a slightly shorter list in older versions of Excel.

differencefrom02

Calculate the Difference

One of my favourite custom calculations is Difference From. It subtracts one pivot table value from another, and shows the result.

In the pivot table below, two copies of the Units field have been added to the pivot table.

  • The heading in the original Units field has been changed to Units Sold.
  • The second Units field is showing the difference from each week’s sales to the previous week’s sales.

differencefrom05

Custom Calculation Tips

If you’re using custom calculations, here are a few tips to make them more effective.

  • To make the data easier to understand, you can change the headings. For example, change from “Sum of Units” to “Units Diff”.
  • You can add another copy of the Units field to the pivot table, and show both the total sales and difference in weekly sales
  • Experiment with the pivot table layout, to find the arrangement that will be easiest to read and understand.

Watch the Difference From Video

To see the steps for creating a Difference From custom calculation, watch this short video.

Download the Sample File

To test the Difference From custom calculation, you can download the sample file from the Custom Calculations page on my Contextures website.

____________________

6 thoughts on “Calculate Differences in a Pivot Table”

  1. Hi, I would like to ask about option i made before but now i forgot it, hot to subtract a field from grand total in pivot table.
    Thanks
    Walaa

  2. Hi! I tried both in office 2013 and 2016 and it seems to me that Excel doesn’t calculater % difference from (previous) for subtotals. Am I doing something wrong? If not, is there a workaround? thanks!

  3. and oups, sorry, I didn’t mean subtotals. I mean:
    Rows: continent,country
    Columns: Quarter, reseller/direct
    values: Revenue, RGrowth (Show value as % difference from previous quarter)
    so for every line I have I have the % difference from correct for revenue growth for partner, for direct but not for its sum. Any way I can attach a screenshot?

    1. Hi Debra, just found your video “Subtotals for Calculated Fields”, thanks for this! but in my case the custom section is grayed out 🙁

      1. reason found: not available when data is extracted from an OLAP cube: https://support.microsoft.com/en-us/help/234700/differences-between-olap-and-non-olap-pivottables-in-excel
        Subtotals
        The following limitations apply when you are working with subtotals in a PivotTable report based on OLAP source data:
        You cannot change the summary function for subtotals in your PivotTable report.
        You cannot display subtotals for inner row or inner column fields in your PivotTable report.
        Because the totals are calculated on the OLAP server, you cannot change the Subtotal hidden page items setting in the PivotTable Options dialog box.

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.