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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
Benjwill
Helper I
Helper I

Dynamic ranking of values selected in slicer, and not rank blank values

Hi, this is my simplified ranking problem:

 

I have a fact table which consists of 3 columns in power BI: Company, Product, and Admin fees. Product is like a primary key of the table. One company can have more than one product, and Admin fees can be blank on some products. I want to create a table visual of this very table, adding a rank measure or column to a table visual of this table, that does the following two things: 1. do not assign a rank to the blank values. 2. when a certain company is selected in the slicer, the rank column would rank only the values displayed for the products on screen. it is like dynamic ranking. Can you help write the dax for this rank measure?

I've tried a number of ways but it didn't work.

 

I've attached my pbix here.

https://drive.google.com/file/d/1o66ym_LCNzv_cAAwYp6z4XXST7NVyZe7/view?usp=sharing

Below is one measure I've tried: 

 

Rank Admin Fees =
RANKX(
    ALLSELECTED('FACT TABLE'[Product]),
    CALCULATE(SUM('FACT TABLE'[Admin Fees]),ALLEXCEPT('FACT TABLE','FACT TABLE'[Product])), ,ASC,Dense)
 
This is my result. Is there a way for blanks to not be ranked? (although blanks must still remain on screen, since we have other columns in the real data that need to be ranked, and on the same table)
 

Benjwill_0-1738558206731.png

 

 

Secondly, I would like the rank to be dynamic like this, when company D is chosen on slicer:

 

Benjwill_1-1738558487960.png

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Benjwill ,
According to your needs, you can first use if statement to exclude the part of the value is empty first, and then sort the remaining data, the following is some of our ideas hope to help your problem!

Measure = 
IF(
    ISBLANK(MAX('FACT TABLE'[Admin Fees])),
    BLANK(),
    RANKX(
        FILTER(
            ALLSELECTED('FACT TABLE'),
            NOT ISBLANK('FACT TABLE'[Admin Fees])  
        ),
        'FACT TABLE'[Admin Fees],                 
        MAX('FACT TABLE'[Admin Fees]),             
        ASC,                                       
        DENSE                                     
    )
)

vxingshenmsft_0-1738646052999.png

 


If you have any other questions, you can check out the pbix file I uploaded, I hope it helps, and I'd be honored if I could solve your problem!

Hope it helps!

Best regards,
Community Support Team_ Tom Shen

If this post helps then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
Benjwill
Helper I
Helper I

Hi thank you greatly for the fast response. However it is not working, not sure if I missed anything.

I put your measure into the model as Rank Admin Fees 2.

It produces rank 2 for all values 😞

 

Benjwill_0-1738562850726.png

 

 

Anonymous
Not applicable

Hi @Benjwill ,
According to your needs, you can first use if statement to exclude the part of the value is empty first, and then sort the remaining data, the following is some of our ideas hope to help your problem!

Measure = 
IF(
    ISBLANK(MAX('FACT TABLE'[Admin Fees])),
    BLANK(),
    RANKX(
        FILTER(
            ALLSELECTED('FACT TABLE'),
            NOT ISBLANK('FACT TABLE'[Admin Fees])  
        ),
        'FACT TABLE'[Admin Fees],                 
        MAX('FACT TABLE'[Admin Fees]),             
        ASC,                                       
        DENSE                                     
    )
)

vxingshenmsft_0-1738646052999.png

 


If you have any other questions, you can check out the pbix file I uploaded, I hope it helps, and I'd be honored if I could solve your problem!

Hope it helps!

Best regards,
Community Support Team_ Tom Shen

If this post helps then please consider Accept it as the solution to help the other members find it more quickly.

Thank you a ton Tom, it worked!

anmolmalviya05
Super User
Super User

Hi @Benjwill, Please try the below measure:

Rank Admin Fees =
VAR AdminFee = SUM('FACT TABLE'[Admin Fees])
RETURN
IF(
ISBLANK(AdminFee),
BLANK(),
RANKX(
FILTER(
ALLSELECTED('FACT TABLE'[Product]),
NOT(ISBLANK(SUM('FACT TABLE'[Admin Fees]))) 
),
CALCULATE(SUM('FACT TABLE'[Admin Fees])),,ASC, DENSE))

 

 

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.