Pivot Calculated formula: SUM(Field1)/AVG(Field2)

前端 未结 3 1649
北荒
北荒 2020-12-16 18:30

I\'ve a simple table with some amount and interval in sec by date and product name.

Month | Product | Amount | Interval in sec
------------------------------         


        
相关标签:
3条回答
  • 2020-12-16 18:57

    You need to refer to the pivot table data in your formula, something like this:

    =GETPIVOTDATA("Sum of Amount",$A$3,"Product","A")/GETPIVOTDATA("Average of Interval",$A$3,"Product","A")

    Edit: From your spreadsheet: To add your desired column to Pivot Table A:

    K5=GETPIVOTDATA("Sum of Amount",$H$2,"Month",DATE(2012,5,1),"Product","Prod A")/GETPIVOTDATA("Average of Interval",$H$2,"Month",DATE(2012,5,1),"Product","Prod A")
    K6=GETPIVOTDATA("Sum of Amount",$H$2,"Month",DATE(2012,5,1),"Product","Prod B")/GETPIVOTDATA("Average of Interval",$H$2,"Month",DATE(2012,5,1),"Product","Prod B")
    K7=GETPIVOTDATA("Sum of Amount",$H$2,"Month",DATE(2012,5,1),"Product","Prod C")/GETPIVOTDATA("Average of Interval",$H$2,"Month",DATE(2012,5,1),"Product","Prod C")
    

    You can also produce the column by adding an extra column to the original data table of: Amount/Sec for each individual entry then when you pivot all the data the product of that column will be your desired result.

    Edit (2):

    The formulas above are cell formulas not pivot table formulas which can't use references sorry I didn't make that clear. I am looking into a pivot table calculation formula but for now the above as a column alongside your pivot table should produce what you need.

    0 讨论(0)
  • 2020-12-16 19:03

    In case anyone else comes across this problem, a solution that I've found is to add a helper "Count" column to your data set, where each record has a 1 entered under the "Count" field.

    Then, in order to achieve the effect of an Average, you can use:

    SUM(FIELD_TO_AVERAGE)/SUM(COUNT)

    I believe this should work in all cases where an average is needed, but I haven't tested it very broadly.

    0 讨论(0)
  • 2020-12-16 19:05

    make a field in the source (counter) and put "1" in every line. put it also into the pivot and divide the SUM of seconds with this field - then it Will be an average. divide the original field with this average so your final-final division Will be the amount per sum of seconds per counter and that Will make the trick :)

    0 讨论(0)
提交回复
热议问题