Forum Discussion
RANKX in total row
Hi!
Can anyone help me with the RANKX. How to use the rank result for "My product" as a total row value (6 instead of 1)
My formula is Rank = RANKX(ALL('Table'[Level 2]),CALCULATE(SUM('Table'[Sum])))
- Anonymous5 years ago
Hi AlexanderK ,
Try this measure
Rank = VAR tt = RANKX ( ALL ( 'Table' ), CALCULATE ( SUM ( 'Table'[Value] ) ) ) VAR _tt = ADDCOLUMNS ( 'Table', "rank", RANKX ( ALL ( 'Table' ), CALCULATE ( SUM ( 'Table'[Value] ) ) ) ) RETURN IF ( HASONEVALUE ( 'Table'[Product] ), tt, MAXX ( FILTER ( _tt, [Product] = "My product" ), [rank] ) )You can check more details from here.
Best Regards,
Stephen Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
2 Replies
- amitchandak
Super User
AlexanderK , Rank is only based on context passed
try like
My formula is Rank = RANKX(ALL('Table'[Level 2], 'Table'[Level 1]),CALCULATE(SUM('Table'[Sum])))
For Rank Refer these links
https://radacad.com/how-to-use-rankx-in-dax-part-2-of-3-calculated-measures - AnonymousNot applicable
Hi AlexanderK ,
Try this measure
Rank = VAR tt = RANKX ( ALL ( 'Table' ), CALCULATE ( SUM ( 'Table'[Value] ) ) ) VAR _tt = ADDCOLUMNS ( 'Table', "rank", RANKX ( ALL ( 'Table' ), CALCULATE ( SUM ( 'Table'[Value] ) ) ) ) RETURN IF ( HASONEVALUE ( 'Table'[Product] ), tt, MAXX ( FILTER ( _tt, [Product] = "My product" ), [rank] ) )You can check more details from here.
Best Regards,
Stephen Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.