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

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

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
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 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.