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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch 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
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.