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

Rankx for a Hierarchy

Hi All,

 

I am having trouble getting my matrix to sort based on a selected value from the slicer. For example, if the selected value is "Base Salary" then I would like the base salary column to be sorted in DEC order and the same idea with the Tota Salary column. The drill-down of the matrix is [Job Title] -> [Name], I would like it to only sort the Job title
Thank you in advance!

ManalYunes_0-1638856800686.png

 

5 REPLIES 5
Anonymous
Not applicable

Hi  @Anonymous ,

Can you try to directly click the small arrow below to control whether the column is in reverse or positive order.

vyangliumsft_0-1639120678700.png

Best Regards,

Liu Yang

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

amitchandak
Super User
Super User

@Anonymous , You can create two ranks measure or vars 

 

Rank1 = RANKX(ALL(Table[Job Title]), [salary])

Rank2 = RANKX(ALL(Table[Name]), [salary])

 

Switch rank = Switch( True() ,

isinscope(Table[Name]) , [Rank2],

isinscope(Table[Job Title]) , [Rank1],

blank()

)

 

 

https://xxlbi.com/blog/new-dax-function-isinscope/

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

Hi   amitchandak! Thanks for your quick response,
I tried this just now, It is not working when I have the [Name] field as the second level to the heiarchy. Am I missing something?

@Anonymous ,

 

Switch rank = Switch( True() ,

isinscope(Table[Name]) , [Rank2],

isinscope(Table[Job Title])  && not(isinscope(Table[Name]) ) , [Rank1],

blank()

)

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

Unfortunately, this is not working either... 

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.