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
aerizk
Helper II
Helper II

Show top N/Rank based on multiple dimensions

Hello, 

 

I have a table with the format below with dimensions coming from multiple tables and sales coming from the fact table.

I would like to be able to filter the table based on the top N values of the combination of the columns. However the only way to use top N is on one dimension only.

I then tried to create a rank measure using CROSSJOIN but it is not working properly and sometimes when I see the ranking it puts a ranking of 2 for example to two rows that have completely different numbers.

 

My goal is to be able to create a Rank Measure for the combination of the three columns below of Country, Product, and Year without having to combine them in one column.

 

My Rank measure should result in the below:

 

 

CountryProductSalesYearRank
USA1000020241
ESA200020246
FRB500020243
AAA100020249
PTB150020247
USB550020252
ESB400020254
FRA350020255
AAD800202510
PTA120020258

 

Thanks a lot!

1 ACCEPTED SOLUTION
Ritaf1983
Super User
Super User

Hi @aerizk 
If your model is something like :

Ritaf1983_0-1711182373828.png

You can use the DAX :

rank_ = if (ISBLANK([total_sales]),blank(),RANKX(all('Table'),[total_sales],,DESC))
The result :
Ritaf1983_1-1711182426005.png

PBIX is attached

If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile

View solution in original post

3 REPLIES 3
aerizk
Helper II
Helper II

hi Rita, that works. Thanks a lot!

@aerizk 

Happy to help 😊

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile
Ritaf1983
Super User
Super User

Hi @aerizk 
If your model is something like :

Ritaf1983_0-1711182373828.png

You can use the DAX :

rank_ = if (ISBLANK([total_sales]),blank(),RANKX(all('Table'),[total_sales],,DESC))
The result :
Ritaf1983_1-1711182426005.png

PBIX is attached

If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile

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.