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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

Sort by columns by value in Matrix Visual

I have a table contains ID and Week columns as below
IDWeek
001Week1
002Week2
003Week2
001Week3
003Week3
003Week3

And I use these 2 to create the Matrix Visual, and the value is Count of ID (I want to calculate how many times that each ID shows in different weeks)
The Matrix Visual is as below:

 Week1Week2Week3Total
0011 12
002 1 1
003 123

Now I can sort by Total column only.
My question is: If I want to sort by Week3, the visual should change to:

 Week1Week2Week3Total
003 123
0011 12
002 1 1
     
What should I do?

I already know that it's not possible to sort by value only.
But is there any way that I can get closer to the expected output? Like using ISINSCOPE function maybe?
Any answer will be helpful! Thanks!!

1 ACCEPTED SOLUTION
Sahir_Maharaj
Super User
Super User

Hello @Anonymous,

 

This isn't directly supported through standard sorting options, but you can achieve the result by creating a custom measure and using it to sort the matrix.

SortByWeek3 = 
CALCULATE(
    COUNT('YourTable'[ID]),
    FILTER(
        'YourTable',
        'YourTable'[Week] = "Week3"
    )
)

Add this measure to your matrix visual (You can add it as a hidden column if you don't want it to be displayed) and sort by the SortByWeek3 measure.

 

Hope this helps.


Did I answer your question? Mark my post as a solution, this will help others!

If my response(s) assisted you in any way, don't forget to drop me a "Kudos" 🙂

Kind Regards,
Sahir Maharaj
Data Scientist | Data Engineer | Data Analyst | AI Engineer
P.S. Want me to build your Power BI solution? (Yes, its FREE!)
➤ Lets connect on LinkedIn: Join my network of 15K+ professionals
➤ Join my free newsletter: Data Driven: From 0 to 100
➤ Website: https://sahirmaharaj.com
➤ Email: sahir@sahirmaharaj.com
➤ Want me to build your Power BI solution? Lets chat about how I can assist!
➤ Join my Medium community of 30K readers! Sharing my knowledge about data science and artificial intelligence
➤ Explore my latest project (350K+ views): Wordlit.net
➤ 100+ FREE Power BI Themes: Download Now
LinkedIn Top Voice in Artificial Intelligence, Data Science and Machine Learning

View solution in original post

2 REPLIES 2
Sahir_Maharaj
Super User
Super User

Hello @Anonymous,

 

This isn't directly supported through standard sorting options, but you can achieve the result by creating a custom measure and using it to sort the matrix.

SortByWeek3 = 
CALCULATE(
    COUNT('YourTable'[ID]),
    FILTER(
        'YourTable',
        'YourTable'[Week] = "Week3"
    )
)

Add this measure to your matrix visual (You can add it as a hidden column if you don't want it to be displayed) and sort by the SortByWeek3 measure.

 

Hope this helps.


Did I answer your question? Mark my post as a solution, this will help others!

If my response(s) assisted you in any way, don't forget to drop me a "Kudos" 🙂

Kind Regards,
Sahir Maharaj
Data Scientist | Data Engineer | Data Analyst | AI Engineer
P.S. Want me to build your Power BI solution? (Yes, its FREE!)
➤ Lets connect on LinkedIn: Join my network of 15K+ professionals
➤ Join my free newsletter: Data Driven: From 0 to 100
➤ Website: https://sahirmaharaj.com
➤ Email: sahir@sahirmaharaj.com
➤ Want me to build your Power BI solution? Lets chat about how I can assist!
➤ Join my Medium community of 30K readers! Sharing my knowledge about data science and artificial intelligence
➤ Explore my latest project (350K+ views): Wordlit.net
➤ 100+ FREE Power BI Themes: Download Now
LinkedIn Top Voice in Artificial Intelligence, Data Science and Machine Learning
Ritaf1983
Super User
Super User

Hi @Anonymous 
Unfortunately, this functionality is not available with the core matrix, and I don't believe there are any workarounds to address this.
Please vote on the idea about the issue (I voted):

https://ideas.fabric.microsoft.com/ideas/idea/?ideaid=1513f45d-a47a-4326-adbe-8bb0023da6c8

But I free matrix in the marketplace with the needed sorting functionality :

Ritaf1983_1-1722088083339.png

 

You need to get with the mouse cursor to the wanted column and give a right click to see the sort "menu".
From here, the first click will sort the column in descending order and, the second ascending.

Ritaf1983_2-1722088357814.pngRitaf1983_3-1722088379445.pngRitaf1983_4-1722088405340.png

The pbix with the example 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
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

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 community update carousel

Fabric Community Update - June 2025

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