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 fails after filtering

Hi all

I have come across a RANKX issue. I basically want to rank locations by a score from a measure, a very simple thing which works for DESC rankings and also works for ASC rankings if nothing is filtered. However, when I filter the whole page to remove some locations, the ASC Ranking only starts at 2 (probably beacuse the filtered locations get blanks?)

 

Here's the Measure:

 

Turnover Rank = RANKX(
ALLSELECTED('PowerBI_DCMAdmin ALL_Dim_Location'[SiteCode]);[Annualized Staff Turnover];;ASC;Dense)

 

 

It all works fine when showing all locations (no filter on the page):

1.png

But when I filter for certain locations, the rank now starts only at 2:

2.png

 

Anybody know what's going wrong?

 

Thanks for the help!

2 ACCEPTED SOLUTIONS
amitchandak
Super User
Super User

@Anonymous , first check do you have blank location or a location is missing in the master/dimesnion table. Address that first.

Filter blank from address and check

Try like

Turnover Rank = RANKX(
ALLSELECTED('PowerBI_DCMAdmin ALL_Dim_Location'[SiteCode]);calculate([Annualized Staff Turnover],not(isblank('PowerBI_DCMAdmin ALL_Dim_Location'[SiteCode])));;ASC;Dense)

 

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

View solution in original post

PaulDBrown
Community Champion
Community Champion

@Anonymous 

The BLANKS may well be the culprits.

Try:

Turnover Rank =
RANKX (
    FILTER (
        ALLSELECTED ( 'PowerBI_DCMAdmin ALL_Dim_Location'[SiteCode] );
        NOT ( ISBLANK ( [Annualized Staff Turnover] ) )
    );
    [Annualized Staff Turnover];
    ;
    ASC;
    DENSE
)




Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






View solution in original post

4 REPLIES 4
Anonymous
Not applicable

Hi @PaulDBrown @amitchandak 

 

Thanks for the quick guidance! I was aware of the blanks possibly causing issues, but could not find a way to filter them out, this has helped!

BUT technically speaking, if a SiteCode was to have a Blank Annualized Turnover, it should get rank 1. But there is no site that is blank... so the lowest value should get rank 1...unless I am simply not able to see some blank sites. Weird, huh?

@Anonymous 

One way of forcing a value is by simply "adding 0" to your base measure. For example say your 

[Annualized Staff Turnover] were:

Annualized Staff Turnover = SUM(table[staff turnover])

You can force a value (and avoid blanks) with:

Annualized Staff Turnover = SUM(table[staff turnover]) + 0

 

 

 

 





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






PaulDBrown
Community Champion
Community Champion

@Anonymous 

The BLANKS may well be the culprits.

Try:

Turnover Rank =
RANKX (
    FILTER (
        ALLSELECTED ( 'PowerBI_DCMAdmin ALL_Dim_Location'[SiteCode] );
        NOT ( ISBLANK ( [Annualized Staff Turnover] ) )
    );
    [Annualized Staff Turnover];
    ;
    ASC;
    DENSE
)




Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






amitchandak
Super User
Super User

@Anonymous , first check do you have blank location or a location is missing in the master/dimesnion table. Address that first.

Filter blank from address and check

Try like

Turnover Rank = RANKX(
ALLSELECTED('PowerBI_DCMAdmin ALL_Dim_Location'[SiteCode]);calculate([Annualized Staff Turnover],not(isblank('PowerBI_DCMAdmin ALL_Dim_Location'[SiteCode])));;ASC;Dense)

 

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
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

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!

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