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

View all the Fabric Data Days sessions on demand. View schedule

Reply
Antmkjr
Post Patron
Post Patron

Sort Column in a matrix by another column

https://drive.google.com/file/d/1kJpyOsEsR5Yl-xr0nUY7Ds-mJNT-bMXe/view?usp=sharing

 

AnuTomy_0-1626326285319.png

How to sort the column in matrix ,in this case Business Unit ,by Salary (The Business Unit with highest salary should come first)

 

9 REPLIES 9
Anonymous
Not applicable

Hi @Antmkjr You can do the following:

1. Go to More Options by clicking on the ellipsis icon (three dots) on the matrix visual.Aditya_Meshram_0-1626335059040.png

2. Select Sort by > Salary

Aditya_Meshram_1-1626335190101.png

3. This is the output. 

Aditya_Meshram_2-1626335262284.png

Hope this answers your question. 

 

AnuTomy_2-1626338368007.png

 

 

 

Thanks for reply, but my requirement is the Business Unit with highest salary should come first, in this case Houston city should be displayed first, then New York city, then Seattle and Los Angeles

 

Hi @Antmkjr ,

 

Create a column as below:

Rank = RANKX('Human Resources',SUMX(FILTER('Human Resources','Human Resources'[Business Unit]=EARLIER('Human Resources'[Business Unit])),'Human Resources'[Salary]),,DESC,Dense)

Then duplicate column "Business Unit" and choose sort by rank:

vkellymsft_0-1626678450187.png

And you will see:

vkellymsft_1-1626678534592.png

For the related .pbix file,pls see attached.

 

Best Regards,
Kelly

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

 

Brilliant !

One more question, if we are putting a filter on department, how to still make it work?

 

AnuTomy_0-1626852833557.png

 

Hi  @Antmkjr ,

 

Sorry,I couldnt find a good way to realize it,currently matrix only support column ranking,row ranking can only be fixed by my trick.

I can only do a ranking measure to show the ranking,but I cant make it rank dynamically per your request:

measure_Rank = IF(ISINSCOPE('Human Resources'[Departmets]),BLANK(), RANKX(ALLSELECTED('Human Resources'[Business Unit]),CALCULATE(SUM('Human Resources'[Salary]),ALLEXCEPT('Human Resources','Human Resources'[Business Unit],'Human Resources'[Departmets])),,DESC,Dense))

vkellymsft_0-1626861605325.png

Check my .pbix file attached.

 

Best Regards,
Kelly

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

Thanks alot for your time, let us wait and see if someone can help any further!

Hi  @Antmkjr ,

 

I have a deep thought about this case,and I'm 99% sure that columns cant be sorted dynamically based on selection in matrix.

You could propose your idea with comments via below link to make this function realize soon.

https://ideas.powerbi.com/ideas/

 

 

Best Regards,
Kelly

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

amitchandak
Super User
Super User

@Antmkjr , You can sort on total columns(Values) in matrix and on rows columns

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

How to sort on columns? In this case i want to sort it by Business Unit which is column.

The Business unit with highest salary should come first.

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.

Top Solution Authors
Top Kudoed Authors