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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
deepu2108
Frequent Visitor

DAX RANK - At different Hierarchy

I have three tables as shown below. I need to find the rank at store,product level based on units sold.Also,in the view I need another rank column whcih displays rank of the product at city,product,Rank1 based on the units sold

 

 

Location

CountrySATECITYStore
USTEXASPLANO1
USTEXASPLANO2
USTEXASIRVING3
USTEXASIRVING4
USTEXASDALLAS5
USTEXASDALLAS6

 

Product

productcatproductsubcatproductname
C1SC1P1
C1SC1P2
C1SC1P3
C1SC2P4
C1SC2P5
C1SC2P6

 

FactSales

Storeproductnamesalesunit
1P12
1P23
1P31
1P42
2P35
2P21
2p11
3P42
3P11
3P23
3P51

 

 

1 ACCEPTED SOLUTION
v-frfei-msft
Community Support
Community Support

Hi @deepu2108 ,

 

Here I create the relationship between tables as below.

 

rela.PNG

 

Then I create three measures.

 

Measure = CALCULATE(SUM(Factsales[salesunit]))
ranklocation = IF(ISBLANK([Measure]),BLANK(),RANKX(ALL(Location),[Measure],,DESC,Dense))
rankproduct = IF(ISBLANK([Measure]),BLANK(),RANKX(ALL('Product'),[Measure],,DESC,Dense))

 

Capture.PNG

 

Regards,

Frank

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

View solution in original post

3 REPLIES 3
v-frfei-msft
Community Support
Community Support

Hi @deepu2108 ,

 

Here I create the relationship between tables as below.

 

rela.PNG

 

Then I create three measures.

 

Measure = CALCULATE(SUM(Factsales[salesunit]))
ranklocation = IF(ISBLANK([Measure]),BLANK(),RANKX(ALL(Location),[Measure],,DESC,Dense))
rankproduct = IF(ISBLANK([Measure]),BLANK(),RANKX(ALL('Product'),[Measure],,DESC,Dense))

 

Capture.PNG

 

Regards,

Frank

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

Hi @deepu2108 ,

 

Does that make sense? If so, kindly mark my answer as the solution to close the case please. Thanks in advance.

 

Regards,
Frank

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.
christianfcbmx
Post Patron
Post Patron

Hi @deepu2108 

 

Im not quite sure about what you want...according to what I understand, you want to create 3 rank measures, right?

 

If you create a total store units measure, you could do this: (if this work, dont forget to give a like) see ya.

 

 

 

Spoiler
RANK CITY = RANKX(ALL('Stores Details');[Total Sales U];;DESC)
Spoiler
RANK PRODUCT = RANKX(ALL('Products details'[productname]);[Total Sales U];;DESC)
Spoiler
RANK STORE = RANKX(ALL('Stores Details'[Store];'Stores Details'[Store]);[Total Sales U];;DESC)

You will get something like these:

 

Captura1.JPG

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

Find out what's new and trending in the Fabric Community.