Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Calculated field with pivot columns

Posted on 2013-12-06
4
Medium Priority
?
417 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 1200 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 34

Assisted Solution

by:Rob Henson
Rob Henson earned 800 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: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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

In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
This article describes a serious pitfall that can happen when deleting shapes using VBA.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

885 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