Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Neo_44
Frequent Visitor

RANKX on a conditionally derived measure skips at random and create false ties

I have a rank formula that ranks people based on a 'Score' ;this is column 2. This score is a measure that calculates a number based on weights assigned for multiple factors  like Avg sales, YoY change,etc to produce an overall score.; this is column 3.  

Neo_44_0-1690222172402.png

Column 2 is ranking values in column 3 based on the following formula:

 

 

Overall RTD Rank FF = 
var x1=IF(NOT (ISBLANK ([Overall RTD Score FF])),RANKX(FILTER(ALLSELECTED('SUP-SR by Format'[ASM]),NOT(ISBLANK([Overall RTD Score FF]))),[Overall RTD Score FF],,ASC))


var x2=IF(NOT (ISBLANK([Overall RTD Score FF])),RANKX(FILTER(ALLSELECTED('SUP-SR by Format'[SR ]),NOT(ISBLANK([Overall RTD Score FF]))),[Overall RTD Score FF],,ASC,Dense))

return

IF(ISINSCOPE('SUP-SR by Format'[SR ]) ,x2,x1)

 

 

All works as expected. However, there is a requirement that for certain branches the can buy or column 1 should be greater than a certain threshold. So I created a column 5 measure that will score only those above that threshold for the specified branches like so.

 

 

CB Overall RTD Score FF = 
 IF(SELECTEDVALUE('SUP-SR by Format'[BRANCH])="A" || SELECTEDVALUE('SUP-SR by Format'[BRANCH])= "B"|| SELECTEDVALUE('SUP-SR by Format'[BRANCH])= "C",
  IF([Can Buy]>30,
    ([AVG Sales Rank FF]*0.15+[Sales % Change Rank FF]*0.20+[MPD Rank FF]*0.15+[MPD % Change Rank FF]*0.50)),
    IF(SELECTEDVALUE('SUP-SR by Format'[BRANCH])<>"A"|| SELECTEDVALUE('SUP-SR by Format'[BRANCH])<>"B"||SELECTEDVALUE('SUP-SR by Format'[BRANCH])<> "C",
    ([AVG Sales Rank FF]*0.15+[Sales % Change Rank FF]*0.20+[MPD Rank FF]*0.15+[MPD % Change Rank FF]*0.50)
    )
 )
        

 

 

This works just fine as well. 
The issue arises when I now try to rank by this newly created column 5.
Column 4 is ranking values in column 5 based on the following formula (Very similar to how column2 was ranking column3):

 

 

Overall RTD CB_Rank FF = 
var x1=IF(NOT (ISBLANK ([CB Overall RTD Score FF])) ,RANKX(FILTER(ALLSELECTED('SUP-SR by Format'[ASM]),NOT(ISBLANK([CB Overall RTD Score FF]))),[CB Overall RTD Score FF],,ASC))

var x2=IF(NOT (ISBLANK([CB Overall RTD Score FF])),RANKX(FILTER(ALLSELECTED('SUP-SR by Format'[SR ]),NOT(ISBLANK([CB Overall RTD Score FF]))),[CB Overall RTD Score FF],,ASC,Dense))

return

IF(ISINSCOPE('SUP-SR by Format'[SR ]) ,x2,x1)

 

 

This resultant rank in column 4 starts at 2 instead of 1, skips 4 and 5 and falsely ties 8th places for three people like highlighted below. 

Neo_44_1-1690223161141.png

Could someone please point me to what I am doing wrong here? 

2 REPLIES 2
Neo_44
Frequent Visitor

@amitchandak I tried the change but I am still getting the same result.

amitchandak
Super User
Super User

@Neo_44 , Try if this change can help

 

overall rtd cb_rank ff =
if(not(isblank([cb overall rtd score ff])),
rankx(filter(allselected('sup-sr by format'[asm]),not(isblank([cb overall rtd score ff]))),[cb overall rtd score ff],,asc),
blank())

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.