Forum Discussion
How to Calculate Subtotal of Other Rows (Exclude Current Row Value)
- 5 years ago
Anonymoustry this
_test = IF ( OR ( OR ( ISINSCOPE ( SM[srg] ), ISINSCOPE ( SM[sds] ) ), ISINSCOPE ( SM[loc] ) ), CALCULATE ( SUM ( CS1[metric1_subtotal] ), ALLSELECTED ( CS1 ) ) - SUMX ( CS1, CS1[metric1_subtotal] ), IF ( HASONEVALUE ( SM[sdv] ), VAR _1 = MAX ( SM[sdv] ) VAR _2 = CALCULATE ( SUMX ( CS1, CS1[metric1_subtotal] ), FILTER ( ALLSELECTED ( SM ), SM[sdv] <> _1 ) ) RETURN _2, SUMX ( CS1, CS1[metric1_subtotal] ) ) )
Anonymouscan you try this as a measure?
_x :=
IF (
HASONEVALUE ( SM[sdv] ),
VAR _1 =
MAX ( SM[sdv] )
VAR _2 =
CALCULATE (
SUMX ( CS1, CS1[metric1_subtotal] ),
FILTER ( ALLSELECTED ( SM ), SM[sdv] <> _1 )
)
RETURN
_2,
SUMX ( CS1, CS1[metric1_subtotal] )
)
smpa01 - Thanks for sharing this approach!
It seems to work fine at the 'sdv' level (Level-1), but when i drill down to 'srg' (Level-2), it doesn't seem to follow the drill-level rows.
Thoughts?
- smpa015 years agoCommunity Champion
AnonymousI am not sure how do you envision the calculation to pan out on a drill down level
On individualsdv level (non-subtotal filter context), I am telling my measure to calculate evrything but that particular sdv level. So with sdv=2, it sums up 4+5+7+10.
When you drill down and gove to sdv->srg lvel what do you plan this measure to return for sdv-srg level with 2-20 and 2-51?
- Anonymous5 years agoNot applicable
For 2-20 would it be possible to display 727 (870 - 143), instead of 640
For 2-51 would it be possible to display 783 (870 - 87), instead of 640
Also, would that carry if we drill down to Level-3, 'sds' ?
- smpa015 years agoCommunity Champion
Anonymoustry this
_test = IF ( OR ( OR ( ISINSCOPE ( SM[srg] ), ISINSCOPE ( SM[sds] ) ), ISINSCOPE ( SM[loc] ) ), CALCULATE ( SUM ( CS1[metric1_subtotal] ), ALLSELECTED ( CS1 ) ) - SUMX ( CS1, CS1[metric1_subtotal] ), IF ( HASONEVALUE ( SM[sdv] ), VAR _1 = MAX ( SM[sdv] ) VAR _2 = CALCULATE ( SUMX ( CS1, CS1[metric1_subtotal] ), FILTER ( ALLSELECTED ( SM ), SM[sdv] <> _1 ) ) RETURN _2, SUMX ( CS1, CS1[metric1_subtotal] ) ) )
- smpa015 years agoCommunity Champion
Anonymous try this and see if it works as you desired
Measure := IF ( OR ( OR ( ISINSCOPE ( SM[srg] ), ISINSCOPE ( SM[sds] ) ), ISINSCOPE ( SM[loc] ) ), SUMX ( CS1, CS1[metric1_subtotal] ), IF ( HASONEVALUE ( SM[sdv] ), VAR _1 = MAX ( SM[sdv] ) VAR _2 = CALCULATE ( SUMX ( CS1, CS1[metric1_subtotal] ), FILTER ( ALLSELECTED ( SM ), SM[sdv] <> _1 ) ) RETURN _2, SUMX ( CS1, CS1[metric1_subtotal] ) ) )