Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.
Hi All,
I am trying to use single RANKX formula in a matrix table so that the rank is calculated correctly when I drill down.
The image below shows the correct rank for LP
But when I drill down, the rank is not calculated correctly. The Rank Total Sales (Brand) shows the correct rank
I tried the following RANK formula but it's not calculating correctly
Rank Total Sales =
VAR LPGROUPRANK =
RANKX(
ALL(
'OCS-daily-2018-2023'[lp_group]
),
[Total Sales],
,
DESC,
Dense
)
VAR BRANDRANK =
RANKX(
ALLSELECTED(
'OCS-daily-2018-2023'[brand]
),
[Total Sales],
,
DESC,
Dense
)
RETURN
SWITCH(
TRUE(),
ISINSCOPE('OCS-daily-2018-2023'[lp_group]
),
LPGROUPRANK,
ISINSCOPE(
'OCS-daily-2018-2023'[brand]
),
BRANDRANK
)
My model looks like this:
Any help is greatly appreciated
Solved! Go to Solution.
Hi @aleivar
You can try the following measure
Rank Total Sales =
VAR LPGROUPRANK =
RANKX (
ALLSELECTED ( 'OCS-daily-2018-2023'[lp_group] ),
[Total Sales],
,
DESC,
DENSE
)
VAR BRANDRANK =
RANKX (
SUMMARIZE (
FILTER (
ALLSELECTED ( 'OCS-daily-2018-2023' ),
[lp_group] = SELECTEDVALUE ( 'OCS-daily-2018-2023'[lp_group] )
),
[brand]
),
[Total Sales],
,
DESC,
DENSE
)
RETURN
IF ( ISINSCOPE ( 'OCS-daily-2018-2023'[brand] ), BRANDRANK, LPGROUPRANK )
Best Regards!
Yolo Zhu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @aleivar
You can try the following measure
Rank Total Sales =
VAR LPGROUPRANK =
RANKX (
ALLSELECTED ( 'OCS-daily-2018-2023'[lp_group] ),
[Total Sales],
,
DESC,
DENSE
)
VAR BRANDRANK =
RANKX (
SUMMARIZE (
FILTER (
ALLSELECTED ( 'OCS-daily-2018-2023' ),
[lp_group] = SELECTEDVALUE ( 'OCS-daily-2018-2023'[lp_group] )
),
[brand]
),
[Total Sales],
,
DESC,
DENSE
)
RETURN
IF ( ISINSCOPE ( 'OCS-daily-2018-2023'[brand] ), BRANDRANK, LPGROUPRANK )
Best Regards!
Yolo Zhu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.