Solved

Excel Advanced Pivot / Calculated Field

Posted on 2013-06-13
5
658 Views
Last Modified: 2013-06-14
Basically, what I'm trying to do is to present data in a pivot table, but include summary results of a different group.  See attachment for full example.  

I'd like to have the results that are in parenthesis in the example below as the summary of the pivot (% of Old Class in New Class).


Detail of Data:
Inv ID      Description Old Class      New Class      Total      New Class Sum    
1      Dodge          Car              4-Wheeler      $5,000       5000                    
2      Mongoose    Bike              2-Wheeler      $200       1000                    
3      Yamaha          Motorcycle   2-Wheeler      $700       1000                      
6      Vespa          Scooter              2-Wheeler      $50       1000                      
4      Vespa          Scooter              2-Wheeler      $50       1000
5      Can Am          Motorcycle   3-Wheeler      $80       80


What I'd like to see in a pivot table:

Old Class / New Class          (% of Old Class in New Class)
Bike
     2-Wheeler                        200 / 1000
Car
     4-Wheeler                        5000/5000
Motorcycle
     2-Wheeler                        700/1000
     3-Wheeler                           80/80
Scooter
     2-Wheeler                         100/1000


I'm able to put the numerator and the denominator as different summary values in the pivot.  What I'm not able to do is to divide the two.

I've also tried to add a calculated field and noticed that when I count a calculated field, I get a different result from using the summary type of count in the pivot, but the sum of a calculated field gives the same result as the sum of the pivot summary type. (see attachment for better explanation).
Pivot-Example.xlsx
0
Comment
Question by:kwieckii
  • 2
  • 2
5 Comments
 
LVL 92

Accepted Solution

by:
Patrick Matthews earned 500 total points
ID: 39245380
This is easiest if you create a "helper" column in your source data.

Please see the attached file:

Q-28156571.xlsx

1) I used a Table for the source data

2) I added a helper column, "Result", with formula...

=[@Total]/AVERAGEIFS([New Class Sum],[Old Class],[@[Old Class]],[New Class],[@[New Class]])

3) I created a PT with Old Class and New Class as the row fields, and Sum of Old Class, Avg of New Class, and Sum of Result as the data fields

4) I turned off subtotals for Old Class


You might also like to review this article: http://www.experts-exchange.com/Software/Office_Productivity/Office_Suites/MS_Office/Excel/A_3172-How-to-Automatically-Update-Your-PivotTables-and-PivotCharts.html
0
 

Author Comment

by:kwieckii
ID: 39245672
That was a good idea - adding the result column !!  I'm wondering - what's the reason for using this formula:

=[@Total]/AVERAGEIFS([New Class Sum],[Old Class],[@[Old Class]],[New Class],[@[New Class]])

and not

[@Total] / [@New Class Sum]  ?

Also - any idea why the Calculated Field Count is different than the Pivot Count result?

Another solution is to add another helper column (I named base)- with the value of 1 for all rows.  I was then able to create a calculated field that worked correctly using the sum(base) instead of count(inv id)

Thanks for the link to the article - planning on setting some time this weekend to read.
0
 
LVL 10

Expert Comment

by:GasperK
ID: 39245843
With a calculated column in a pivot table, you can only do one thing, SUM. You can change the function to Count or to anything you like and it will let you but it will not do anything else than SUM and the result will stay the same...
0
 
LVL 92

Expert Comment

by:Patrick Matthews
ID: 39246017
I'm wondering - what's the reason for using this formula:

=[@Total]/AVERAGEIFS([New Class Sum],[Old Class],[@[Old Class]],[New Class],[@[New Class]])

and not

[@Total] / [@New Class Sum]  ?

Brain cramp?  :)

Yes, your simpler formula should work just fine.
0
 

Author Comment

by:kwieckii
ID: 39246569
MP - thanks - just checking in case I missed something.  

Gasper - it's strange that they call it a calculated field if the only calculation you can perform is a sum.  Looking around, it seems the calculated field can support formulas (other than sum), but it probably doesn't work for what I'm trying to accomplish.  I found a good link (below) that explains the usage of calculated fields and I'll be reading it along with MPs post this weekend.

http://www.globaliconnect.com/excel/index.php?option=com_content&view=article&id=141:excel-pivot-tables-insert-calculated-fields-a-calculated-items-create-formulas&catid=81&Itemid=486

Thanks for the help - closing this one out.
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

As with any other System Center product, the installation for the Authoring Tool can be quite a pain sometimes. This article serves to help you avoid making these mistakes and hopefully save you a ton of time on troubleshooting :)  Step 1: Make sur…
Technology opened people to different means of presenting information, but PowerPoint remains to be above competition. Know why PPT still works today.
Learn how to make your own table of contents in Microsoft Word using paragraph styles and the automatic table of contents tool. We'll be using the paragraph styles in Word’s Home toolbar to help you create a table of contents. Type out your initial …
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.

762 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

18 Experts available now in Live!

Get 1:1 Help Now