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! Learn more

Reply
BIMJ
Frequent Visitor

Ranking with condition to avoid blanks and certain values

I was trying to make a rank measure to take rank Customer based on their Sales. However, I need to avoid certain customers such as XXX and blank customers in the ranking or add them to a default ranking. Unfortunately, it is not working for me. Below is an example and the expected output as Rank.

 

CustomerSalesRank
E50001
C20002
XXX600 
B5003
 200 
Z1504
A1005
T506
R107

 

The dax calculation I am using is 

Rank =
IF (
SELECTEDVALUE ( Query1[Customer] ) IN { "XXX", "" }, -100, //applying default rank of -100
RANKX (
FILTER ( ALL ( Query1 ), NOT ( Query1[Customer] IN { "XXX", "" } ) ),
[Sales],
,
DESC
)
)

 

Please help

1 ACCEPTED SOLUTION
BIMJ
Frequent Visitor

I managed to frame the dax with the tips from @DataInsights . Thanks. Below is the final working solution 

 

Ranking Customers Asc =
IF (
    NOT MAX ( Query1[Customers] ) IN { "XXX"BLANK ()"" },
    //Filtering unwanted customers like XXX and blanks
    CALCULATE (
        RANKX ( ALL ( Query1[Customers] ), [Sales],, ASC, DENSE )
    ),
    //applying rank
    100 //giving default rank of 100 to unwanted customer
)

View solution in original post

4 REPLIES 4
BIMJ
Frequent Visitor

I managed to frame the dax with the tips from @DataInsights . Thanks. Below is the final working solution 

 

Ranking Customers Asc =
IF (
    NOT MAX ( Query1[Customers] ) IN { "XXX"BLANK ()"" },
    //Filtering unwanted customers like XXX and blanks
    CALCULATE (
        RANKX ( ALL ( Query1[Customers] ), [Sales],, ASC, DENSE )
    ),
    //applying rank
    100 //giving default rank of 100 to unwanted customer
)

DataInsights
Super User
Super User

@BIMJ,

 

Try this measure:

 

Rank = 
IF (
    NOT MAX ( Query1[Customer] ) IN { "XXX", "" },
    RANKX (
        FILTER ( ALL ( Query1 ), NOT Query1[Customer] IN { "XXX", "" } ),
        [Sales],
        ,
        DESC
    )
)

 

DataInsights_0-1662642341402.png

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Thank you for the help. Unfortunately, it is not working for me. The ranking is random. Please see below screenshot. I am checking on the worst profit (or loss) ranking. 

 

BIMJ_0-1662643978804.png

 

@BIMJ,

 

Please provide a sanitized pbix using one of the file services (e.g., OneDrive) and I'll look at it.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




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