If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > PC based Database Applications > Microsoft Excel > Calculated Fields in Pivot Table

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-29-05, 10:51
csillagyitzik csillagyitzik is offline
Registered User
 
Join Date: Dec 2005
Posts: 3
Calculated Fields in Pivot Table

I'm trying to get a calculated field in a Pivot Table. But not a regular one... Can you look in the example below and let me know if it can be done (and how it can be done)?

I have an Excel database with Toy Boxes. Here is the information about each Toy: Box Number, Box Location, Number of Toys in box, Value of Toys for a specific Toy Type, value of Box.

In the Pivot Table I have the Locations and Boxes in the Rows area, the Type in the Columns area and the value in the data area.

I attached the excel spread sheet (in a zipped file) to this post.

What I want is to have a calculated field for:
1. Number of Toys / Total Value
2. Total Value / Number of Boxes

Can it be done?
Attached Files
File Type: zip PivotTableQuestion.zip (3.0 KB, 326 views)
Reply With Quote
  #2 (permalink)  
Old 12-29-05, 13:20
shades shades is offline
Registered User
 
Join Date: Oct 2003
Posts: 1,091
Howdy and welcome to the board.

Pivottables can be powerful, and frustrating. There are a couple of ways to approach this, but not sure what you still need. On the attachment are two approaches.

PT1 shows what happens when you add a second copy of the same field (Value) but change it to be a percent. in this case, right click on any cell with the second value and choose Options, and then in the middle dropdown choose "% of Total". Then choose number format to make it percent.

PT2, inserts a calculated field (Pivottable toolbar, Pivottable > Formulas > Calculated Field. In the top define the name, then in the next dialog box you can put the formula. Use the fields listed in the lower portion to make the formula.

This probably is not what you want, but it might direct you to solving your problem.
Attached Files
File Type: zip PivotTableQuestion2.zip (4.5 KB, 771 views)
__________________
old, slow, and confused
but at least I'm inconsistent!

Rich
(retired Excel 2003 user, 3/28/2008)

How to ask a question on forums
Reply With Quote
  #3 (permalink)  
Old 12-30-05, 12:11
csillagyitzik csillagyitzik is offline
Registered User
 
Join Date: Dec 2005
Posts: 3
This wasn't what I was looking for...

The 2 examples you gave me are not what I'm looking for. I tried using the same mechanism for what I want but I can't find a way to do it.

Any other ideas?
Reply With Quote
  #4 (permalink)  
Old 12-31-05, 01:10
savbill savbill is offline
Registered User
 
Join Date: Feb 2004
Posts: 533
OK thought I'd take a try at this. First off mixing Box data and Location data in the same pivot table results in an overly complex table that doesn't give clear information for location or box contents. I'd suggest using 2 pivot tables one to show and calculate the Location data and one to show and calculate the Box data. I've attached an example zip file see the 2 pivot tables below your original sample.

The 'Count of Toys in box' Column in your data is not needed and not used in the pivot table as the count of toys can be calculated from the count of Box IDs. Each Toy has a box identifier.

Also be aware of the calculation function. You want to * count * boxes (box ids) and * sum * toy values. When you set up the pivot table it will be necessary to select the data field and set the calc function for each of the fields Boxes and Value.

The Formulas can not be made relative to the cells in the Pivot table. At least I can't see a way of making them relative. This means each time you add data or recreate the pivot table you'll need to set each formula for every row calculation. You can however refer to the cells in your Pivot table. (not sure if you realized this) So the formulas will be like this:

Code:
Total Value / # of Boxes (for each location)
=GETPIVOTDATA("Sum of Value",$A$30,"Location","US")/GETPIVOTDATA("Count of Box",$A$30,"Location","US")

# of Toys / Total Value
=GETPIVOTDATA("Count of Box",$A$40,"Box",1)/GETPIVOTDATA("Sum of Value",$A$40,"Box",1)
Attached Files
File Type: zip PivotTableQuestion3.zip (5.1 KB, 348 views)
__________________
~

Bill
Reply With Quote
  #5 (permalink)  
Old 12-31-05, 01:16
shades shades is offline
Registered User
 
Join Date: Oct 2003
Posts: 1,091
These kinds of examples seem to justify the position of Bill Jelen [MrExcel] and Tracy Syrstad in VBA and Macros for MS Excel, namely that Pivot tables are powerful but frustrating, and much easier to do in VBA than in Excel. At work I have experimented with VBA for Pivot tables and it seems to be true.
__________________
old, slow, and confused
but at least I'm inconsistent!

Rich
(retired Excel 2003 user, 3/28/2008)

How to ask a question on forums
Reply With Quote
  #6 (permalink)  
Old 10-01-09, 07:20
Grinning Crow Grinning Crow is offline
Registered User
 
Join Date: Oct 2009
Posts: 8
This kind of problem can usually be solved with some judicial use of source data editing. Please see the attached, where I have added two fields to the source data table. This achieves the desired result.

PivotTableQuestion3.zip
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On