The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
Hello Everyone,
I'm doing the power BI lab, I have ameasure total sale like below:
And I would like to use RANKX function to rank the Category by total sale:
Solved! Go to Solution.
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
)
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
)
User | Count |
---|---|
24 | |
9 | |
8 | |
7 | |
6 |
User | Count |
---|---|
29 | |
13 | |
11 | |
9 | |
9 |