Forum Discussion
Can the Column Sequence within a Matrix visual be sorted using the column Total
- 2 years ago
Hmmm. Interesting. I haven't tested this, but here's what I'm thinking. You know how Power BI default sort is alphabetically, which presents a problem with Month Names, so in our date table we create a sort column. I'm wondering if you can create a calculated column using RANKX to rank your Companies by Total Profit. Then in your company table, sort your company name by the rank column. Then in your visual, sort by Company ASC. Give that a go and let us know if it works.
**edit: on further thought, I don't think an X function will work as a calculated column. You may need to create a calculated table with SUMMARIZECOLUMNS and RANKX as your expression. Use this output as a dimension of your company table. Then use the company name value from this calculated table as your axis value in your visual.
Hi chonchar - thanks for taking the time to respond but the functionality you are describing sorts the vertical columns in vertical ascending/descending order and doesn't solve the issue described above.
"if someone could explain how the matrix in (2) could be configured to show the Columns in the sequence of
Company B then Company A then Company C from the left to right (i.e. Descending Numerical Order of Total Profit)
that would be great. "
Thanks
Hmmm. Interesting. I haven't tested this, but here's what I'm thinking. You know how Power BI default sort is alphabetically, which presents a problem with Month Names, so in our date table we create a sort column. I'm wondering if you can create a calculated column using RANKX to rank your Companies by Total Profit. Then in your company table, sort your company name by the rank column. Then in your visual, sort by Company ASC. Give that a go and let us know if it works.
**edit: on further thought, I don't think an X function will work as a calculated column. You may need to create a calculated table with SUMMARIZECOLUMNS and RANKX as your expression. Use this output as a dimension of your company table. Then use the company name value from this calculated table as your axis value in your visual.
- RichardJ2 years agoResponsive Resident
Great idea CoreyP which worked perfectly.
Although I did the rank in PowerQuery via an index I'm confident the same approach would work within a calculated column also (using SUMMARIZECOLUMNS and RANKX).
Updated pbix can be found here: https://www.dropbox.com/scl/fi/syn5vuamab9qovj96lpw0/Question_About_Matrix_Sort_Order.pbix?rlkey=1pltjygobmsargg3fg0b6m49c&dl=0The Company Sort Sequence (Greatest to Smallest profit) in the matrix above now matches the order in the graph.
Nice work and thanks for taking the time to respond.
Richard