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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
NM2023
Frequent Visitor

How to rank within a hierarchy but ignoring upper levels

Dear all, 

 

I want to do dynamic ranking within a matrix. I can easily achieve ranking within region (green column), and my question is, how to achieve the ranking across regions (yellow column)? It doesnt seem like the evaluation can break the upper region context. 

Ranking =
var territoryRanking = rankx(allselected(salesHier[Territories]), [TotalSales])
var RegionRanking = rankx(allselected(salesHier[Regions]), [TotalSales])
return if(isinscope(salesHier[Territories]), territoryRanking, if(isinscope(salesHier[Regions]), RegionRanking, blank()))

 

Screenshot 2024-06-09 135948.png

 

Thank you so much!
NM

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Your ideas is great @lbendlin

Hi, @NM2023 

I created a matrix using the following sample data:

vjianpengmsft_0-1718602978731.png

vjianpengmsft_1-1718602991144.png

I created a measure using the following DAX expression:

Measure = 
IF(ISINSCOPE('Table'[territories]),RANKX(ALLSELECTED('Table'),'Table'[Measure 2]))

vjianpengmsft_2-1718603069658.png

I've provided the PBIX file used this time below.

 

 

How to Get Your Question Answered Quickly

If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .

Best Regards

Jianpeng Li

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

 

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Your ideas is great @lbendlin

Hi, @NM2023 

I created a matrix using the following sample data:

vjianpengmsft_0-1718602978731.png

vjianpengmsft_1-1718602991144.png

I created a measure using the following DAX expression:

Measure = 
IF(ISINSCOPE('Table'[territories]),RANKX(ALLSELECTED('Table'),'Table'[Measure 2]))

vjianpengmsft_2-1718603069658.png

I've provided the PBIX file used this time below.

 

 

How to Get Your Question Answered Quickly

If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .

Best Regards

Jianpeng Li

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

 

lbendlin
Super User
Super User

Use REMOVEFILTERS() on the Regions and Territories.

Wilson_
Super User
Super User

NM,

 

Can you please share a sample pbix file? (If you don't know how, please check the pinned thread in the forum.) It would make debugging your issue easier. 🙂




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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