Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Calculated field with pivot columns

Posted on 2013-12-06
4
396 Views
Last Modified: 2013-12-09
I've got a worksheet that looks like this
YEAR |  ITEMNO | REVENUE
-----|---------|-----------------
2010 | number1 | $5
2010 | number1 | $6
2010 | number2 | $10
2011 | number1 | $6
2011 | number2 | $9
2011 | number2 | $6
2012 | number1 | $8
2012 | number2 | $10

Open in new window

I put it into an excel pivot table so the results look like this
ITEMNO  | 2010 |  2011 | 2012 
--------|------|-------|------
number1 | $11  |   $6  |  $8
number2 | $10  |  $15  |  $10

Open in new window

I would like to add a calculated column to the right to calculate the difference between the revenue for of the years like this
ITEMNO  | 2010 |  2011 | 2012 | 10-11 Diff | 11-12 Diff  
--------|------|-------|------|------------|------------
number1 | $11  |   $6  |  $8  |    $-5     |   $2
number2 | $10  |  $15  |  $10 |    $5      |   $-5

Open in new window

Is this something that is possible? If so, how can I do this?
0
Comment
Question by:David11011
4 Comments
 
LVL 39

Accepted Solution

by:
nutsch earned 300 total points
ID: 39702502
Add Revenue a second time as a data field in your pivot
Right-click that second revenue column and pick Show value as...Difference From
Base field: Year / Base Item: Previous
Update the column header

You're done. Sadly there's no way I know to hide the first empty column, but you can hide the column until the next pivot refresh.

Thomas
0
 
LVL 19

Expert Comment

by:helpfinder
ID: 39704581
do you mean something like that on my example?
sample.xlsx
0
 
LVL 33

Assisted Solution

by:Rob Henson
Rob Henson earned 200 total points
ID: 39705773
Something like attached.

Calculated Year on Year movement using a helper column in the data. Against each line the formula gives the same result for each combo of year and account so then displayed in the pivot as Average.

=SUMIFS($C$2:$C$9,$A$2:$A$9,$A2,$B$2:$B$9,$B2)-SUMIFS($C$2:$C$9,$A$2:$A$9,$A2-1,$B$2:$B$9,$B2)

Haven't found a way of putting Variance columns to right hand side.

Solution from helpfinder could be used, ie adding additional formula alongside the pivot but these won't necessarily recalculate correctly by having hardcoded cell references in the formula. You could do similar using GETPIVOTDATA function.

Thanks
Rob H
Pivot-Variance.xlsx
0
 
LVL 2

Author Closing Comment

by:David11011
ID: 39706171
Thank you for your replies this will work just fine for what I am wanting to do. It would be nice to put all the values to the right hand side but I this will work fine. Thank you so much for your help!!!! Exactly what I needed!
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Drop Down List with Unique/Distinct Values (Part II - ComboBox or ListBox and Data Validation List Bonus!) David Miller (dlmille) Intro This article focuses on delivering unique, sorted lists to list objects (e.g., ComboBox, ListBox) and Dat…
Improved? Move/Copy Add-in Replacement - How to avoid the annoying, “A formula or sheet you want to move or copy contains the name XXX, which already exists on the destination worksheet.” David Miller (dlmille)  It was one of those days… I wa…
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question