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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

Rankx to consider a subset filtered using a variable

Hi all,
This is my measure,
OverallScoreVarianceRankNew =
var cmp = if([OverallScoreVariance]=[Overall %],0,if([Overall %]=blank(),0,1))/
var filteredusers = CALCULATE(max('KPI'[NT_UserName]),filter('KPI',cmp=1))

//  I want to rank only those people who have Overall % & ([OverallScoreVariance] <>[Overall %], thats why a filter condition is given here, now I want to rank only these usernames not sure how to achieve this
 
var OverallScore = IF( SELECTEDVALUE('KPI'[NT_UserName]) <> nt, BLANK(), CALCULATE(RANKX(ALL('KPI'[NT_UserName]),[OverallScoreVariance],,DESC,Dense),ALLEXCEPT('KPI','KPI'[NT_UserName],'KPI'[WeekNew]))) // this is my current formula which ranks everyone, not sure how to include a condition here which takes only the filteredusers for ranking

return
 
OverallScore
 
 
any help to modify this would be nice, this is a measure, 'KPI'[NT_UserName],'KPI'[WeekNew] are the data columns
Thanks
3 REPLIES 3
v-jingzhang
Community Support
Community Support

Hi @Anonymous 

 

Can you provide some sample data and expected result in table format so that we can use them to test and check the measures?

 

You may refer to the measure structure in this thread: Rankx with filter - Microsoft Power BI Community. Filter the table provided as the first variable in RANKX() function. 

 

Best Regards,
Community Support Team _ Jing

Anonymous
Not applicable

What if you add an ALLSELECTED ( KPI ) argument to your CALCULATE?

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

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.

Top Solution Authors
Top Kudoed Authors