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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

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 @Anonymous ,

 

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 @Anonymous ,

 

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 @Anonymous ,

 

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 @Anonymous 

 

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
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.