Solved

Calculated field with pivot columns

Posted on 2013-12-06
4
380 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 32

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction While answering a recent question (http:/Q_27311462.html), I created an alternative function to the Excel Concatenate() function that you might find useful.  I tested several solutions and share the results in this article as well as t…
Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.

863 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now