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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Anonymous
Not applicable

RANKX conditional

Hello,

I need some help, I want to create a measure with RANX, but with condition. 

I have a table with Customer and Volume, I need top rank by Volume, but the customer A and D need to be the last in the rank , as bellow:

CustomerVolumeRank
A1004
B501
C302
D514
E283

 

How can I do this? 

 

Thaks!

 

1 ACCEPTED SOLUTION
jdbuchanan71
Super User
Super User

Hello @Anonymous 

Put this formula in as a calculated column on your table.

Ranking = 
VAR BottomCustomers = 
    DATATABLE (
        "Customer",STRING,
        {
            {"A"},
            {"D"},
            {"Add any other customer as a new line"},
            {"One line for each customer to rank on the bottom"}
        }
    )
RETURN
RANKX (
    FILTER ( ALL ( Table1 ), NOT ( Table1[Customer] IN BottomCustomers ) ),
    IF ( Table1[Customer] IN BottomCustomers, -999999, Table1[Volume] )
)

I put a couple extra lines in the list of customers incase you end up needing to add more you can see where they go.
ranking.jpg

View solution in original post

1 REPLY 1
jdbuchanan71
Super User
Super User

Hello @Anonymous 

Put this formula in as a calculated column on your table.

Ranking = 
VAR BottomCustomers = 
    DATATABLE (
        "Customer",STRING,
        {
            {"A"},
            {"D"},
            {"Add any other customer as a new line"},
            {"One line for each customer to rank on the bottom"}
        }
    )
RETURN
RANKX (
    FILTER ( ALL ( Table1 ), NOT ( Table1[Customer] IN BottomCustomers ) ),
    IF ( Table1[Customer] IN BottomCustomers, -999999, Table1[Volume] )
)

I put a couple extra lines in the list of customers incase you end up needing to add more you can see where they go.
ranking.jpg

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

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.