Pivot calculation - variance between count of 2 fields

davemcwish

New Member
Joined
Nov 12, 2013
Messages
11
I'm needing to create a pivot table that dynamically generates a variance between two data fields containing attribute data. I've put a mockup on Dropbox to show the source data (after denormalizing) and the output table I'm trying to produce. I know that I can perform a subtraction either using Cell references or GetPivotData but neither of these will work if the pivot structure changes so I'm looking to embed a calculation within a pivot. I should add that there are additional fields that will be used for analysis but I cut them out from the mockup as they aren't relevant for the calculation.

Thoughts ?
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
That would require a Calculated Item, which isn't possible with your data layout. It would be possible with this layout (Count of item in the Data area):


Excel 2010
ABCD
1ItemCriteriaStateLevel
2#1Criteria AAfterLevel A
3#1Criteria ABeforeLevel A
4#1Criteria BAfterLevel A
5#1Criteria BBeforeLevel A
6#1Criteria CAfterLevel D
7#1Criteria CBeforeLevel D
8#1Criteria DAfterLevel A
9#1Criteria DBeforeLevel A
10#1Criteria EAfterLevel B
11#1Criteria EBeforeLevel A
12#1Criteria FAfterLevel A
13#1Criteria FBeforeLevel A
14#1Criteria GAfterLevel B
15#1Criteria GBeforeLevel A
16#1Criteria HAfterLevel C
17#1Criteria HBeforeLevel B
18#1Criteria IAfterLevel C
19#1Criteria IBeforeLevel B
20#1Criteria JAfterLevel B
21#1Criteria JBeforeLevel A
22#1Criteria KAfterLevel B
23#1Criteria KBeforeLevel A
24#1Criteria LAfterLevel C
25#1Criteria LBeforeLevel B
26#1Criteria MAfterLevel A
27#1Criteria MBeforeLevel A
28#1Criteria NAfterLevel B
29#1Criteria NBeforeLevel A
30#1Criteria OAfterLevel B
31#1Criteria OBeforeLevel B
32#1Criteria PAfterLevel B
33#1Criteria PBeforeLevel A
34#1Criteria QAfterLevel A
35#1Criteria QBeforeLevel A
36#1Criteria RAfterLevel D
37#1Criteria RBeforeLevel D
38#1Criteria SAfterLevel C
39#1Criteria SBeforeLevel B
40#1Criteria TAfterLevel D
41#1Criteria TBeforeLevel D
42#1Criteria UAfterLevel B
43#1Criteria UBeforeLevel B
44#1Criteria VAfterLevel C
45#1Criteria VBeforeLevel B
46#1Criteria WAfterLevel D
47#1Criteria WBeforeLevel D
Sheet2
 
Upvote 0
Ok Andrew, I understand the reasoning behind your suggested layout but you've completely lost me with 'Calculated Item'. If I setup the table with Row = Criteria, Column = Level and Data = Count of State I can't see how to create a calculated item that I will put in the Values area that is = [Count of] State(After) - [Count of] State(Before).
 
Upvote 0
I added a calculated Item with the formula =After-Before:


Excel 2010
FGHIJK
1Count of ItemColumn Labels
2Row LabelsLevel ALevel BLevel CLevel DGrand Total
3Criteria A20002
4After11
5Before11
6Formula100000
7Criteria B20002
8After11
9Before11
10Formula100000
11Criteria C00022
12After11
13Before11
14Formula100000
15Criteria D20002
16After11
17Before11
18Formula100000
19Criteria E02002
20After11
21Before11
22Formula1-11000
23Criteria F20002
Sheet1
 
Upvote 0

Forum statistics

Threads
1,215,641
Messages
6,125,981
Members
449,276
Latest member
surendra75

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top