• Skip to main content
  • Skip to header right navigation
  • Skip to site footer

My Online Training Hub

Learn Dashboards, Excel, Power BI, Power Query, Power Pivot

  • Courses
  • Pricing
    • Free Courses
    • Power BI Course
    • Excel Power Query Course
    • Power Pivot and DAX Course
    • Excel Dashboard Course
    • Excel PivotTable Course – Quick Start
    • Advanced Excel Formulas Course
    • Excel Expert Advanced Excel Training
    • Excel Tables Course
    • Excel, Word, Outlook
    • Financial Modelling Course
    • Excel PivotTable Course
    • Excel for Customer Service Professionals
    • Excel for Operations Management Course
    • Excel for Decision Making Under Uncertainty Course
    • Excel for Finance Course
    • Excel Analysis ToolPak Course
    • Multi-User Pricing
  • Resources
    • Free Downloads
    • Excel Functions Explained
    • Excel Formulas
    • Excel Add-ins
    • IF Function
      • Excel IF Statement Explained
      • Excel IF AND OR Functions
      • IF Formula Builder
    • Time & Dates in Excel
      • Excel Date & Time
      • Calculating Time in Excel
      • Excel Time Calculation Tricks
      • Excel Date and Time Formatting
    • Excel Keyboard Shortcuts
    • Excel Custom Number Format Guide
    • Pivot Tables Guide
    • VLOOKUP Guide
    • ALT Codes
    • Excel VBA & Macros
    • Excel User Forms
    • VBA String Functions
  • Members
    • Login
  • Blog
  • Excel Webinars
  • Excel Forum
    • Register as Forum Member

Excel PivotTable Calculated Items by Position

You are here: Home / Excel PivotTables / Excel PivotTable Calculated Items by Position
PivotTable Calculated Items by Position
July 28, 2015 by Mynda Treacy

A while back I wrote about how to create Excel PivotTable Calculated Items using the conventional approach of referencing the item name in the formula like this:

Excel pivotTable calculate item formulas

But did you know you can also refer to items by their position in the PivotTable relative to the column containing your Calculated Item?

Download the Workbook

Enter your email address below to download the sample workbook.

By submitting your email address you agree that we can email you our Excel newsletter.
Please enter a valid email address.

Download the Excel Workbook. Note: This is a .xlsx file please ensure your browser doesn't change the file extension on download.

Referencing Excel PivotTable Calculated Items by Position

For example, let’s say we have some data by month like so:

Excel pivotTable report

And in column H we want to add a Calculated Item for the rolling average of the last 3 months. In our formula we can reference ‘Apr’ with Month[-1], Mar with Month[-2] and so on. The minus sign tells Excel that the Month column is to the left of our Calculated Field.

Inserting a Calculated Item for Rolling Average

To insert a PivotTable Calculated Item for the rolling 3 month average:

  1. Select a cell in the column labels area of the PivotTable. E.g. click on cell G4 containing ‘Apr’.
  2. Then on the PivotTable Options tab (Excel 2010), or PivotTable Analyze tab (Excel 2013) > Fields, Items & Sets > Calculated Item. This opens the dialog box below:

Excel pivotTable rolling average

  1. Give your new Item a name
  2. Enter your formula; remember I want to AVERAGE the last 3 months, so I will reference the Field name ‘Month’ and in square brackets I’m telling Excel the position of the columns I want it to use relative to the column containing my new Item. So my formula is:
= AVERAGE( Month[-1], Month[-2], Month[-3])

In the image below you can see that Month[-1] is referencing ‘Apr’ as this is the Month column that is one back from the column containing my Calculated Field in column H:

Excel pivotTable calculated items by position

Alternatively if the position of the ‘Average Last 3 Mths’ column was before ‘Jan’ my formula would be:

=AVERAGE(Month[2], Month[3], Month[4])

Excel pivotTable calculated item by position

Referencing Items by Position Gotchas

  • High Maintenance: The above formula with the Average to the left of the data is high maintenance because as new months are added the position of the last 3 months changes relative to the column containing the formula.

    For example, if we added May data then we’d need to edit the formula so that it picked up Month[3], Month[4], and Month[5].

    And before you ask…no you can’t use dynamic ranges in PivotTable Calculated Field/Item formulas 🙂

    I therefore prefer to position of the Last 3 Months column to the right of the data, but that’s not bullet proof either as you’ll see in my next point.

  • Drag & Drop: Putting the ‘Last 3 Months’ column to the right of the month columns doesn’t make it maintenance free. You still have to update it as new months are added because they will be added after your Calculated Item column (as you can see below with ‘May’ being added in column I), but it’s a simple case of dragging the ‘Average Last 3 Months’ column to the end of the PivotTable….just don’t forget to do this!

maintaining pivottable calculated items

  • Filters: Items referred in this way can change whenever the positions of items change or different items are displayed or filtered. Filtered items are not counted in this index.
  • Errors: If the position that you give is before the first item or after the last item in the field, the formula results in a #REF! error.

Use with Caution

So as you can see, referencing Excel PivotTable Calculated Items by Position is a great way to calculate rolling averages, or rolling totals, but you must remember to maintain them or you could end up with some kooky data.

PivotTable Calculated Items by Position

More Excel PivotTables Posts

Auto Refresh PivotTables

Auto Refresh PivotTables isn’t on by default, and the process differs depending on if your PivotTables is loaded to the data model or not.

Show Items with no Data in PivotTables

Show Items with no Data in PivotTables allows you to maintain a constant structure to your PivotTable or Pivot Chart axis when filtering.

Force Excel Slicers to Single Select

There's no build in way to force Excel Slicers to single select but we can use these clever warnings to persuade your users.
excel pivottable p&L

Excel PivotTable Profit and Loss

Creating an Excel PivotTable Profit and Loss Statement means you can use Slicers and Conditional Formatting and have the P&L automatically update.

Excel PivotTable Field List Tips

Customize the Excel PivotTable Field List to suit your needs. Find how to turn the PivotTable Field List on and off and other handy tips.

Hide Blanks in Excel PivotTables

Hide blanks in Excel PivotTables caused by empty cells in your source data. I’m talking about PivotTable cells containing the (blank) placeholder.
Excel Slicer Formatting

Excel Slicer Formatting

Excel Slicer Formatting is essential because they’re big and chunky. In this tutorial I show you the tricks to make Excel Slicers small.
Excel PivotTable Quick Explore

Excel PivotTable Quick Explore

Drill down into data hierarchies using PivotTables and Pivot Charts with Excel PivotTable Quick Explore. New in Excel 2013 onward.
excel online pivottables

Excel Online PivotTables

Excel Online PivotTables are now available from the Insert tab of the ribbon. There are some limitations that are covered in this post.

Excel PivotTable Error Handling

Excel PivotTable error handling and why you can’t calculate the percentage change when the prior period is zero or blank.


Category: Excel PivotTables
Previous Post:Excel SparklinesExcel Sparklines
Next Post:Excel Copy and Paste Visible Cells OnlyExcel Copy and Paste Visible Cells Only

Reader Interactions

Comments

  1. Filipe

    February 20, 2023 at 6:44 am

    This post is perfect! Exactly what I was needing. Thank you!! But, in addition to that, I wish to be able to sort (descending, for example) this calculated column. Any idea how?

    In my Excel, I have an error message with something about positional items.

    Sorry for my poor english.

    Reply
    • Mynda Treacy

      February 20, 2023 at 12:07 pm

      HI Filipe, please post your question on our Excel forum where you can also upload a sample file and we can help you further.

      Reply
  2. Randy Madden

    July 27, 2017 at 2:59 am

    Mynda,

    This seems like the perfect solution for a report I’m trying to build, but I have failed to get it to work. The way I’m trying to implement it is the same as yours (variance between columns) with one exception: my years (I’m using years instead of months) have 3 columns each (Buys/Revenue/ARP), whereas your example has only one column for each month. Does this method ONLY work for single columns, or should I theoretically be able to get this to work? Thanks, Randy Madden

    Reply
    • Mynda Treacy

      July 27, 2017 at 8:47 am

      Hi Randy,

      My gut feel is that it should work. Can you please upload a sample Excel file to our Excel Forum with your question so we can see what you’re working with.

      Thanks,

      Mynda

      Reply
  3. MF

    July 29, 2015 at 12:13 pm

    Hi Mynda,

    This is a nice feature in Pivot Table, which I believe many people (including myself) are not aware of it. Thanks for sharing.

    Nevertheless, as you have illustrated, there are some limitations and have to USE WITH CAUTION.

    One more point to the CAUTION:
    The % renewal calculated in this way is only the average of the % renewal, NOT the result from aggregated (Renewal / (Initial + Renewal)). So we have to be careful in interpreting the “average” of “% renewal”.

    Cheers,
    MF

    Reply
    • Mynda Treacy

      July 29, 2015 at 1:06 pm

      Cheers, MF. Good point in regards to the average of % Renewal.

      Mynda

      Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Current ye@r *

Leave this field empty

Sidebar

More results...

launch excel macros course excel vba course

Featured Content

  • 10 Common Excel Mistakes to Avoid
  • Top Excel Functions for Data Analysts
  • Secrets to Building Excel Dashboards in Less Than 15 Minutes
  • Pro Excel Formula Writing Tips
  • Hidden Excel Double-Click Shortcuts
  • Top 10 Intermediate Excel Functions
  • 5 Pro Excel Dashboard Design Tips
  • 5 Excel SUM Function Tricks
  • 239 Excel Keyboard Shortcuts

100 Excel Tips and Tricks eBook

Download Free Tips & Tricks

Subscribe to Our Newsletter

Receive weekly tutorials on Excel, Power Query, Power Pivot, Power BI and More.

We respect your email privacy

239 Excel Keyboard Shortcuts

Download Free PDF

mynda treacy microsoft mvpHi, I'm Mynda Treacy and I run MOTH with my husband, Phil. Through our blog, webinars, YouTube channel and courses we hope we can help you learn Excel, Power Pivot and DAX, Power Query, Power BI, and Excel Dashboards.

Blog Categories

  • Excel
  • Excel Charts
  • Excel Dashboard
  • Excel Formulas
  • Excel PivotTables
  • Excel Shortcuts
  • Excel VBA
  • General Tips
  • Online Training
  • Outlook
  • Power Apps
  • Power Automate
  • Power BI
  • Power Pivot
  • Power Query
microsoft mvp logo
trustpilot excellent rating
Secured by Sucuri Badge
MyOnlineTrainingHub on YouTube Mynda Treacy on Linked In Mynda Treacy on Instagram Mynda Treacy on Twitter Mynda Treacy on Pinterest MyOnlineTrainingHub on Facebook
 

Company

  • About My Online Training Hub
  • Disclosure Statement
  • Frequently Asked Questions
  • Guarantee
  • Privacy Policy
  • Terms & Conditions
  • Testimonials
  • Become an Affiliate

Support

  • Contact
  • Forum
  • Helpdesk – For Technical Issues

Copyright © 2023 · My Online Training Hub · All Rights Reserved. Microsoft and the Microsoft Office logo are trademarks or registered trademarks of Microsoft Corporation in the United States and/or other countries. Product names, logos, brands, and other trademarks featured or referred to within this website are the property of their respective trademark holders.