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
Avdakushina
New Member

Please help with rankx and further visualisation

Hello everybody!

Just looking for some help with rankx function. 

I have a table that contains information about products sold on a disaggregated basis by segment, manufacturer, total units and product name. I need to rank Products based on total units sold. So my formula is 

Rank = RANKX (ALLSELECTED('Product'), SalesFact[Total Units])
But further visualisation is incorrect. I need to create a tree diagram showing 3 best selling products by "Abbas" manufacturer in three segments (All season, Moderation and Extreme). So i want to see 9 products in my diagram, 3 in each segment. Avdakushina_0-1663334958584.png

But the outcome is the following:

Avdakushina_1-1663335036568.png

So I only see the first 3 best selling products, not 3 best selling products in each category. 

What is wrong here? 

Looking forward to your answer

1 ACCEPTED SOLUTION
GdBreems
Frequent Visitor

Hey, maybe you can fix it as follows:
 
Rank =
RANKX(
     ALLEXCEPT(Table,Table[Manufacturer],Table[Segment]),
     [Measure on which rank is based],,DESC
)
 
This way you get a rank per segment for each manufacturer.
Then in the Visual you can put a filter in the filterpane where Rank < 4.
 
Edit -> Changed [Measure/Calculation on which rank is based] to [Measure on which rank is based].
RankX only seemed to work when refering to a measure, not when putting the calculation within said measure directly into RankX, anyone knows why?

View solution in original post

1 REPLY 1
GdBreems
Frequent Visitor

Hey, maybe you can fix it as follows:
 
Rank =
RANKX(
     ALLEXCEPT(Table,Table[Manufacturer],Table[Segment]),
     [Measure on which rank is based],,DESC
)
 
This way you get a rank per segment for each manufacturer.
Then in the Visual you can put a filter in the filterpane where Rank < 4.
 
Edit -> Changed [Measure/Calculation on which rank is based] to [Measure on which rank is based].
RankX only seemed to work when refering to a measure, not when putting the calculation within said measure directly into RankX, anyone knows why?

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.