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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
ellac
Helper III
Helper III

RANKX with filter

Hi!

I'm trying to create a DAX measure using RANKX, but I need help. I start with the table to the left where I see all my products and what rank they have based on sales. Then I want to be able to filter on a supplier, for example Supplier = "Supplier1", and then see the product's ranks based on all the products with no Supplier filter applied.

ellac_0-1673450688728.png

For the left table I get the right output by this measure:

RANKX(
ALL('Table'[Product], 'Table'[Supplier]),
[Sales]
)

 

But I don't get the right output for the right table using the measure...

Any ideas on how to solve this?

 

Thanks in advance!

/Ella

 

 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @ellac ,

 

I doubt that [Sales] here is a field without summarize.

vcgaomsft_0-1674554576787.png

If so, please sum this field.

vcgaomsft_1-1674554671622.png

then please new:

Total Sales = SUM('Table'[Sales])
Rank = RANKX(ALL('Table'[Product],'Table'[Supplier]),[Total Sales])

vcgaomsft_2-1674554807896.png

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

View solution in original post

5 REPLIES 5
Anonymous
Not applicable

Hi @ellac ,

 

I doubt that [Sales] here is a field without summarize.

vcgaomsft_0-1674554576787.png

If so, please sum this field.

vcgaomsft_1-1674554671622.png

then please new:

Total Sales = SUM('Table'[Sales])
Rank = RANKX(ALL('Table'[Product],'Table'[Supplier]),[Total Sales])

vcgaomsft_2-1674554807896.png

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

amitchandak
Super User
Super User

@ellac , Issue is not very clear. Please try with allselected

 

RANKX(
ALLSELECTED('Table'[Product], 'Table'[Supplier]),
[Sales]
)

 

If this does not help
Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

 

For Rank Refer these links
https://radacad.com/how-to-use-rankx-in-dax-part-2-of-3-calculated-measures
https://radacad.com/how-to-use-rankx-in-dax-part-1-of-3-calculated-columns
https://radacad.com/how-to-use-rankx-in-dax-part-3-of-3-the-finale
https://community.powerbi.com/t5/Community-Blog/Dynamic-TopN-made-easy-with-What-If-Parameter/ba-p/3...

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

Hi,

Sorry about that! Will try to make the issue clearer. I want to create a measure that, when filtering a table, shows the ranking of the filtered products in a context as if the filter is not applied, i.e. when I filter on

"Supplier1", I want to see that product A has rank 1 and product F has rank 6, which is the total ranking of all products without any filter on supplier.

When using your measure, I get the following result:

ellac_0-1673517306092.png

When filtering on "Supplier1" I want to show Product A as rank 1, and product F as rank 6 - not rank 2. Unfortunately my organization doesn't allow me to share files over the internet...

Thanks!!

Best regards,

Ella

 

Hello Ellac 

Hope you're doing well.

 

I'm facing the same issue with rankx measure. Were you able to find a solution ?

 

Thank you for the support

Hi @Rachid1679,

 

Yes! The accepted solution of this thread worked 🙂 The resulting measure was this:

 

VAR __variableRank = RANKX(ALL('Table'[Product], 'Table'[Supplier]), [Sales])
RETURN
        IF(
            __variableRank < 101,
            __variableRank,
            BLANK()
        )
 
I ended the measure expression with an if statement which gives me top 100 on the ranking.
 
Hope it works for you too!
/Ella

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors