Forum Discussion
thangdev
2 years agoRegular Visitor
RANKX function - need help explain
Hello Everyone, I'm doing the power BI lab, I have ameasure total sale like below: Total Sales = SUMX('Order Details', 'Order Details'[Quantity] * 'Order Details'[UnitPrice]) And I would like ...
- 2 years ago
Hi thangdev
In the 2nd formula CALCULATE is missing to perform context transition.
While in the 1st formula you referenced a measure and all measures are automatically wrapped with an implicit CALCULATE therefore, automatically perform context transition.You can use either of the following
= RANKX ( ALLSELECTED ( Categories ), SUMX ( CALCULATETABLE ( 'Order Details' ), 'Order Details'[Quantity] * 'Order Details'[UnitPrice] ), , ASC )= RANKX ( ALLSELECTED ( Categories ), CALCULATE ( SUMX ( 'Order Details', 'Order Details'[Quantity] * 'Order Details'[UnitPrice] ) ), , ASC )
tamerj1
2 years agoCommunity Champion
Hi thangdev
In the 2nd formula CALCULATE is missing to perform context transition.
While in the 1st formula you referenced a measure and all measures are automatically wrapped with an implicit CALCULATE therefore, automatically perform context transition.
You can use either of the following
=
RANKX (
ALLSELECTED ( Categories ),
SUMX (
CALCULATETABLE ( 'Order Details' ),
'Order Details'[Quantity] * 'Order Details'[UnitPrice]
),
,
ASC
)=
RANKX (
ALLSELECTED ( Categories ),
CALCULATE (
SUMX ( 'Order Details', 'Order Details'[Quantity] * 'Order Details'[UnitPrice] )
),
,
ASC
)