Forum Discussion
manually order matrix columns
Hi
I have used the matrix tool to summarise my data but need to change the order of the column headers and was wondering how to go about doing this as I can currently only sort by totals or alphabetically. My matrix layout is belo
Days in Status Bucket ||| 0-2 | 6-7 | 8-14 | 3-5 | 15+|
-------------------------------------------------------
a ||| - | - | - | - | - |
b ||| - | - | - | - | - |
c ||| - | - | - | - | - |
d ||| - | - | - | - | - |
I want order these in terms of the ascending days in status buckets, any ideas?
You could do it either way. I would use a SWITCH expression (instead of nested IFs) in your calculated column. Something like
SortOrder = SWITCH(Table[Column], "0-2",1,"6-7",2,"8-14",3,"3-5",4,"15+",5,6)
where Table[Column] is replaced by the column used in your matrix columns
If this works for you, please mark it as the solution. Kudos are appreciated too. Please let me know if not.
Regards,
Pat
4 Replies
- mahoneypatMicrosoft Employee
You'll need to use the Sort By Column feature in Power BI. Please see these links, but basically you'll add a column in the same table as your bins column with the sort order.
https://docs.microsoft.com/en-us/power-bi/create-reports/desktop-sort-by-column
https://www.youtube.com/watch?v=4xapOrfLvbg
If this works for you, please mark it as the solution. Kudos are appreciated too. Please let me know if not.
Regards,
Pat
- LParker97Helper I
Thanks mahoneypat can this be done by doing an IF statement for each result or by grouping?
- mahoneypatMicrosoft Employee
You could do it either way. I would use a SWITCH expression (instead of nested IFs) in your calculated column. Something like
SortOrder = SWITCH(Table[Column], "0-2",1,"6-7",2,"8-14",3,"3-5",4,"15+",5,6)
where Table[Column] is replaced by the column used in your matrix columns
If this works for you, please mark it as the solution. Kudos are appreciated too. Please let me know if not.
Regards,
Pat