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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request 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
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.