Forum Discussion
Percent of Total
- 10 years ago
Greg_Deckler, I think you meant to use CALCULATE() or switched the order there.
TotalQuantity = SUM( 'Table'[Quantity] ) % Total = [TotalQuantity] / CALCULATE( [TotalQuantity] ,ALL( 'Table' ) ) ***OR*** TotalQuantity = SUM( 'Table'[Quantity] ) % Total = [TotalQuantity] / SUMX( ALL( 'Table' ) ,'Table'[Quantity] )Either construction would work, but I'd lean toward the former idiom.
Greg_Deckler, I think you meant to use CALCULATE() or switched the order there.
TotalQuantity =
SUM( 'Table'[Quantity] )
% Total =
[TotalQuantity]
/ CALCULATE(
[TotalQuantity]
,ALL( 'Table' )
)
***OR***
TotalQuantity =
SUM( 'Table'[Quantity] )
% Total =
[TotalQuantity]
/ SUMX(
ALL( 'Table' )
,'Table'[Quantity]
)Either construction would work, but I'd lean toward the former idiom.
Yeah, I totally fubarred that DAX formula, what I was going for was:
= SUM([Quantity])/SUMX('table',ALL('table'[Quantity]))
I like you splitting it out into separate measures though, makes it cleaner and easier to understand.
That's what I get thinking I can do this stuff from memory sometimes instead of actually firing up Desktop and doing it.
- konstantinos10 years ago
Memorable Member
Greg_Decklergreggyb I would suggest always use DIVIDE function as it doesn't return errors on zero values and at most data models is faster..Unless you have any other opinion I would love to hear it..
And you guys are super fast - and with well explained answers!!!
- Greg_Deckler10 years ago
Community Champion
konstantinos, that's a great point, I always forget about DIVIDE.
- konstantinos10 years ago
Memorable Member
Greg_Deckler too much modelling on the first versions of powerpivot/ssas :smileywink: