cancel
Showing results for 
Search instead for 
Did you mean: 

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

Reply
ellac
Helper II
Helper II

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
v-cgao-msft
Community Support
Community Support

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

3 REPLIES 3
v-cgao-msft
Community Support
Community Support

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...

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

 

Helpful resources

Announcements
PBI November 2023 Update Carousel

Power BI Monthly Update - November 2023

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

Community News

Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

Power BI Fabric Summit Carousel

The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors
Top Kudoed Authors