Forum Discussion
Measure and sort in matrix
Hello
I am hoping someone can help with my challenge. I have looked online and I may be overcomplicating my issue.
Screen shot of dashboard
I have a measure that allows me to select Year, month, to compare data across years. The matrix you can see has two measures. Both feed from the DAX measure in Solved: Re: Dynamic Time comparison across multiple years - Microsoft Fabric Community.
I would like to order by values in the columns. But when I click on the triangle icon it does not sort correctly. Can I sort my values in a column defined by a measure?
Thank you,
Stuart
You will laugh when I tell you the answer ....
Change the data type from Text to a Number
Text will sort alphabetically and left justify like this.
The promlem will fix itself when you use a number instead of text
Please click thumbs up and accept solution. Thank you !
3
301
32
4
405
43
5 Replies
- speedramps
Super User
You will laugh when I tell you the answer ....
Change the data type from Text to a Number
Text will sort alphabetically and left justify like this.
The promlem will fix itself when you use a number instead of text
Please click thumbs up and accept solution. Thank you !
3
301
32
4
405
43
- maruthisp
Super User
Hi StuartPQY,
Please change the Actuals column data type as Whole Number.
Also, you can sort 2 columns by using shift key on keyboard and click one by one column to sort on multiple columns in a visual.
One more thing, if youare using Text columns in calculations in mesaures then there might chances of error as well.If this reply helped solve your problem, please consider clicking "Accept as Solution" so others can benefit too. And if you found it useful, a quick "Kudos" is always appreciated, thanks!
Best Regards,
Maruthi
- Nasif_Azam
Super User
Hey StuartPQY ,
Thanks for sharing the screenshot and explaining your challenge. It looks like you're using a matrix visual in Power BI, displaying two DAX measures: one for Prior Year Actuals and one for Actuals. You're trying to sort the matrix by one of these measures, but the sorting doesn't work as expected. Let's go over why this might be happening and how to fix it.
There are 3 option to correct sorting
Option 1: Use a Single Dynamic Measure Instead of Two Static Measures
If you're using two separate measures like [Prior Yr Actuals] and [Actuals], consider creating one dynamic measure that returns the correct value based on slicer selections (like year or period offset). This way, you’ll only have one measure in the matrix, which makes sorting much more reliable.
Option 2: Switch to Table Visual Instead of Matrix
If you don't need the row/column hierarchy provided by the matrix visual:
-
Switch to a table visual, which allows sorting directly by measure columns more reliably.
-
Add [Supplier Name], [Prior Yr Actuals], [Actuals] as separate columns.
Option 3: Use a Sort Column
Create a calculated column to help sorting: SortOrder = SELECTEDMEASURE()
Then sort the matrix by that measure, using the Sort Order column (you may need to change visual type or tweak formatting).
For Detailed Information:
https://community.fabric.microsoft.com/t5/Desktop/Sort-Matrix-by-Measure/td-p/142742
https://community.fabric.microsoft.com/t5/Desktop/Sort-Matrix-by-Value-not-working/td-p/417722If you found this solution helpful, please consider accepting it and giving it a kudos (Like) it’s greatly appreciated and helps others find the solution more easily.
Best Regards,
Nasif Azam -
- AnonymousNot applicable
Hi StuartPQY ,
Thank you for reaching out to the Microsoft Fabric Community. Also thank you speedramps , maruthisp and Nasif_Azam for your insights.
I wanted to check if you had the opportunity to review the information provided. Please feel free to contact us if you have any further questions. If the response has addressed your query, please accept it as a solution and give a 'Kudos' so other members can easily find it.
Thank you. - StuartPQYFrequent Visitor
Hello
Thank you for the replies. Pologies for the delay in reply, ive not been able to look at this PBI report at work. I will do so today.
ThanksStuart