+ Reply to Thread
Results 1 to 6 of 6

Calculated field (Sum) in Pivot tables

  1. #1
    Registered User
    Join Date
    01-17-2019
    Location
    Scotland
    MS-Off Ver
    365
    Posts
    66

    Question Calculated field (Sum) in Pivot tables

    Hi,

    I have attached a sample tab of the issue I am having … I'm getting better with Pivot tables but can't quite work out the way around this.


    I have a table (attached) that has red, blue and green cars each with their individual car colour total target value.

    The pivot table correctly sums the "Total" values for blue, green and red cars and displays the correct individual target for each colour (I'm using "max" as the value field setting to get the common value [all the same for a car colour] rather than sum which would, wrongly, give a summed total of individual cars).

    The bit I cant get to work is that I want the difference between the "sum of total" (pivot column C) and "max of target" (pivot column D) … at the moment it is summing the "Target" data (A2:A12) for each car:

    Example for "Red Cars": (7922.90*2)-1200 rather than (7922.90)-1200

    I understand why its totalling but cant find a way to force it to just use the single value (the value I found using "max")

    Anyone got a simple/clever/complex but understandable to my lizard brain fix for this?


    Thanks
    Attached Files Attached Files

  2. #2
    Registered User
    Join Date
    01-17-2019
    Location
    Scotland
    MS-Off Ver
    365
    Posts
    66

    Re: Calculated field (Sum) in Pivot tables

    Sorry just noticed another thing with the "max of target" column in the pivot table … is there a way to total the 3 maxes so that the bottom row (D21) is their total not the maximum value?

  3. #3
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 2019
    Posts
    17,569

    Re: Calculated field (Sum) in Pivot tables

    According to this Contextures article the only function that can be used in a calculated field is SUM, so you will not be able to use the MAX of the target.
    Therefore I would recommend adding a column to the source data populated using: =SUMIF(C$2:C$12,C2,G$2:G$12)-LARGE((C$2:C$12=C2)*(A$2:A$12),1)
    That column is then used as the variance in the values field of the pivot table (in this case "average" is employed as the type of calculation)
    I believe that I am correct in saying that the Grand Total row can not be manipulated to show the SUM of a column containing MAX values (it will display MAX itself)
    As a work around I produced a helper column (which may be moved and/or hidden for aesthetic purposes) using a GETPIVOTDATA formula which may be dragged:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    Just to rub a little salt in that wound, you would not want to display the SUM below the pivot table as expanding the table would overwrite the formula so cell D15 contains: =SUM(I18:I30)
    Let us know if you have any questions.
    Attached Files Attached Files
    Consider taking the time to add to the reputation of everybody that has taken the time to respond to your query.

  4. #4
    Registered User
    Join Date
    01-17-2019
    Location
    Scotland
    MS-Off Ver
    365
    Posts
    66

    Re: Calculated field (Sum) in Pivot tables

    Thanks for the reply JeteMc … been away so just getting back to this.

    I only recently got into Pivot tables so slowly finding my way!

    I originally did a sum below the pivot but, as you said, it doesn't push it down it just overwrites

    I will keep hacking at it - your response is most helpful in finding my way

    Cheers

  5. #5
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 2019
    Posts
    17,569

    Re: Calculated field (Sum) in Pivot tables

    You're Welcome. Thank You for the feedback and for marking the thread as 'Solved'. I hope that you have a blessed day.

  6. #6
    Registered User
    Join Date
    01-17-2019
    Location
    Scotland
    MS-Off Ver
    365
    Posts
    66

    Re: Calculated field (Sum) in Pivot tables

    @jetemc

    Actually cracked it with a bit of a bodge … I created a helper column with a unique identifier "IF(E10="","",(COUNTIF(E10:E23,E10)=1)+0)" which returned a 1 or a zero plus added a "difference" column … used the 1 or 0 to blank any duplicate calc's allowing me to only have one instance of each number and therefore I could use simple totals!

    I always tended to avoid hidden helper columns but the more I look at Pivot tables the more it seems to be the way to go

    very much appreciate the assist!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Pivot Tables - Calculated Field Help
    By keithfender in forum Excel General
    Replies: 3
    Last Post: 06-18-2015, 12:10 PM
  2. Pivot Tables Calculated Field
    By yawnzzzz in forum Excel General
    Replies: 2
    Last Post: 05-23-2012, 09:29 AM
  3. Replies: 1
    Last Post: 04-12-2010, 01:01 PM
  4. Pivot Tables - How do I add Functions as a Calculated Field?
    By ColinS via OfficeKB.com in forum Excel General
    Replies: 1
    Last Post: 03-16-2010, 12:02 PM
  5. Calculated field in Pivot Tables
    By JILL in forum Excel General
    Replies: 2
    Last Post: 04-28-2006, 11:00 AM
  6. Calculated field in pivot tables
    By nc in forum Excel General
    Replies: 1
    Last Post: 12-02-2005, 09:40 AM
  7. pivot tables:calculated field
    By mariagloria in forum Excel General
    Replies: 2
    Last Post: 02-28-2005, 06:06 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1