Sep 10 2021 04:33 AM
Hello,
I am trying to sum the Qty by Quarter, taking into account the selection (eg. using slicers on Cat & Product). It's kind of a combination of ALLSELECTED and ALLEXCEPT.
I would have thought (cfr. also this solution) that the formula below would work, but it doesn't: it doesn't take Quarter into account and instead sums the whole Qty column.
Any help would be greatly appreciated!
=CALCULATE(SUM(Table1[Qty]); ALLSELECTED(Table1); VALUES(Table1[Quarter]))
Sep 10 2021 12:24 PM
SolutionSuch formula is for the measure, not calculated column. In general it's better to avoid calculated columns at all and use only measures, with very few exceptions.
Sum Selected by Quarter:=CALCULATE (
SUM ( Table1[Qty] ),
ALLSELECTED ( Table1 ),
VALUES ( Table1[Quarter] )
)
I'm not sure what you'd like to calculate. What this measure do
For the QuarterRank = 4 we have values in quarters 1 and 4 (returned by ALLSELECTED). With that measure calculates sum of qty for all quarters 1 and 4, now independently of the rank, totally 116.
Sep 10 2021 11:55 PM
Sep 11 2021 02:12 AM
@bartvana , glad it helped
Sep 10 2021 12:24 PM
SolutionSuch formula is for the measure, not calculated column. In general it's better to avoid calculated columns at all and use only measures, with very few exceptions.
Sum Selected by Quarter:=CALCULATE (
SUM ( Table1[Qty] ),
ALLSELECTED ( Table1 ),
VALUES ( Table1[Quarter] )
)
I'm not sure what you'd like to calculate. What this measure do
For the QuarterRank = 4 we have values in quarters 1 and 4 (returned by ALLSELECTED). With that measure calculates sum of qty for all quarters 1 and 4, now independently of the rank, totally 116.