Pivot table custom total formula

%3CLINGO-SUB%20id%3D%22lingo-sub-2117995%22%20slang%3D%22en-US%22%3EPivot%20table%20custom%20total%20formula%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2117995%22%20slang%3D%22en-US%22%3E%3CP%3EHello%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20have%20created%20a%20pivot%20table%2C%20however%20I%20am%20stuck%20on%203%20calculations%2C%202%20of%20which%20are%20show%20on%20the%20attached%20screenshot.%20I%20am%20trying%20to%20see%20how%20I%20can%20customize%20a%20specific%20cell%20calculation.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EFor%20example%20in%20the%20highlighted%20cell%20with%2035.09%25%20(which%20is%20calculating%20an%20average%20of%20above%20cells)%2C%20I%20need%20it%20to%20calculate%20%22Daily%20GP%20total(%2416%2C895.99)%2FDaily%20sales%20total(39%2C853.16)%22%20from%20cells%20to%20left%20which%20should%20be%2042.39%25.%20I%20cannot%20figure%20out%20how%20to%20customize%20these%20certain%20cells.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThank%20you%20in%20advance%20to%20anyone%20that%20can%20help.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2117995%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EFormulas%20and%20Functions%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EMacros%20and%20VBA%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EPower%20BI%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2118332%22%20slang%3D%22en-US%22%3ERe%3A%20Pivot%20table%20custom%20total%20formula%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2118332%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F959620%22%20target%3D%22_blank%22%3E%40vince2397%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIt's%20bit%20hard%20to%20discuss%20that%20with%20screenshots%20only.%3C%2FP%3E%0A%3CP%3EFirst%2C%20I%20assume%20you%20are%20on%20Excel%20for%20Windows%20desktop%20on%20version%20which%20works%20with%20data%20model%20(majority%20of%20them).%3C%2FP%3E%0A%3CP%3ECreating%20PivotTable%20check%20the%20box%20as%20on%20screenshot%20to%20add%20data%20to%20data%20model%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22image.png%22%20style%3D%22width%3A%20556px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F253438i2B36DE1DB76730A9%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22image.png%22%20alt%3D%22image.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3EFor%20this%20sample%20you%20may%20add%20measure%20as%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-excel%22%3E%3CCODE%3EPercent%20Measure%3A%3DIF(HASONEVALUE(Table1%5BDate%5D)%2C%0A%20%20%20%20%20%20%20AVERAGE(Table1%5BPercent%5D)%2C%0A%20%20%20%20%20%20%20SUM(Table1%5BProfit%5D)%2FSUM(Table1%5BSales%5D)%0A)%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22image.png%22%20style%3D%22width%3A%20491px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F253440i15608C214B5A5A31%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22image.png%22%20alt%3D%22image.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3EThe%20idea%20is%20takes%20average%20of%20profit%20if%20only%20one%20day%20selected%20(e.g.%20for%20each%20row%20of%20the%20PivotTable)%20and%20if%20few%20days%20are%20selected%20(i.e.%20for%20Grand%20Total)%20it%20calculates%20profit%20for%20total%20numbers%2C%20not%20average%20of%20averages.%20Result%20is%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22image.png%22%20style%3D%22width%3A%20430px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F253441i3C5F58ED49981EF3%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22image.png%22%20alt%3D%22image.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2118207%22%20slang%3D%22en-US%22%3ERe%3A%20Pivot%20table%20custom%20total%20formula%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2118207%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F521%22%20target%3D%22_blank%22%3E%40Sergei%20Baklan%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20found%20where%20you%20were%20referencing%20but%20receive%20the%20following%20attached%20error%20once%20trying%20to%20%22Add%20New%20Measure%22%3F%3F%20Thanks.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EVin%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2118105%22%20slang%3D%22en-US%22%3ERe%3A%20Pivot%20table%20custom%20total%20formula%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2118105%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F521%22%20target%3D%22_blank%22%3E%40Sergei%20Baklan%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20am%20sorry%2C%20can%20you%20give%20me%20a%20bit%20more%20direction%20as%20to%20where%20I%20would%20enter%2Fadd%20this%3F%20This%20type%20of%20pivot%20is%20beyond%20my%20area%20of%20expertise%20so%20I%20am%20learning.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThank%20you%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2118021%22%20slang%3D%22en-US%22%3ERe%3A%20Pivot%20table%20custom%20total%20formula%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2118021%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F959620%22%20target%3D%22_blank%22%3E%40vince2397%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EAdding%20data%20to%20data%20model%20you%20may%20add%20DAX%20measure%20like%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-excel%22%3E%3CCODE%3EPerCent%3A%3DIF(HASONEVALUE(Table%5BDate%5D)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20AVERAGE(Table%5BPercent%5D)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20SUM(Table%5BDaily%20GP%5D)%2FSUM(Table%5BDaily%20sales%5D)%0A)%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
New Contributor

Hello,

 

I have created a pivot table, however I am stuck on 3 calculations, 2 of which are show on the attached screenshot. I am trying to see how I can customize a specific cell calculation.

 

For example in the highlighted cell with 35.09% (which is calculating an average of above cells), I need it to calculate "Daily GP total($16,895.99)/Daily sales total(39,853.16)" from cells to left which should be 42.39%. I cannot figure out how to customize these certain cells. 

 

Thank you in advance to anyone that can help.

4 Replies

@vince2397 

Adding data to data model you may add DAX measure like

PerCent:=IF(HASONEVALUE(Table[Date]),
            AVERAGE(Table[Percent]),
            SUM(Table[Daily GP])/SUM(Table[Daily sales])
)

 

@Sergei Baklan 

 

I am sorry, can you give me a bit more direction as to where I would enter/add this? This type of pivot is beyond my area of expertise so I am learning.

 

Thank you

@Sergei Baklan 

 

I found where you were referencing but receive the following attached error once trying to "Add New Measure"?? Thanks.

 

Vin

@vince2397 

It's bit hard to discuss that with screenshots only.

First, I assume you are on Excel for Windows desktop on version which works with data model (majority of them).

Creating PivotTable check the box as on screenshot to add data to data model

image.png

For this sample you may add measure as

Percent Measure:=IF(HASONEVALUE(Table1[Date]),
       AVERAGE(Table1[Percent]),
       SUM(Table1[Profit])/SUM(Table1[Sales])
)

image.png

The idea is takes average of profit if only one day selected (e.g. for each row of the PivotTable) and if few days are selected (i.e. for Grand Total) it calculates profit for total numbers, not average of averages. Result is

image.png