Forum Discussion
Maintaining Custom Order in Power BI Stacked Column Chart's X-axis
I have a dataset in Power BI structured as:
| b76-b74 | 0 |
| b74-b72 | 0 |
| b72-b70 | 8 |
| b70-b68 | 14 |
| b68-b66 | 14 |
| b66-b64 | 20 |
| b64-b62 | 22 |
| b62-b60 | 22 |
| b60-b58 | 30 |
| b58-b56 | 28 |
| b56-b54 | 4 |
| b54-b52 | 4 |
| b52-b50 | 12 |
| b50-b48 | 0 |
| b48-b46 | 8 |
| b46-b44 | 8 |
| b44-b42 | 2 |
| b42-b40 | 2 |
| b40-b38 | 2 |
| b38-b36 | 2 |
| b36-b34 | 2 |
| b34-b32 | 2 |
| b32-b30 | 2 |
| b30-b28 | 16 |
| b28-b26 | 16 |
| b26-b24 | 24 |
| b24-b22 | 16 |
| b22-b20 | 22 |
| b20-b18 | 22 |
| b18-b16 | 6 |
| b16-b14 | 0 |
| b14-b12 | 0 |
| b12-b10 | 0 |
| b10-b8 | 0 |
| b8-b6 | 0 |
| b6-b4 | 0 |
| b4-b2 | 0 |
When I create a stacked column chart, Power BI seems to sort the rango column in an unexpected order. For instance, 'b8-b6' appears right before 'b76-b74'. I would assume Power BI thinks b8 is larger than b76.
I attempted to maintain the order by adding a 'SortOrder' column, which assigns a unique number to each row based on my preferred order:
rangocountSortOrder
| b76-b74 | 0 | 1 |
| b74-b72 | 0 | 2 |
| b72-b70 | 8 | 3 |
| b70-b68 | 14 | 4 |
| b68-b66 | 14 | 5 |
| b66-b64 | 20 | 6 |
| b64-b62 | 22 | 7 |
| b62-b60 | 22 | 8 |
| b60-b58 | 30 | 9 |
| b58-b56 | 28 | 10 |
| b56-b54 | 4 | 11 |
| b54-b52 | 4 | 12 |
| b52-b50 | 12 | 13 |
| b50-b48 | 0 | 14 |
| b48-b46 | 8 | 15 |
| b46-b44 | 8 | 16 |
| b44-b42 | 2 | 17 |
| b42-b40 | 2 | 18 |
| b40-b38 | 2 | 19 |
| b38-b36 | 2 | 20 |
| b36-b34 | 2 | 21 |
| b34-b32 | 2 | 22 |
| b32-b30 | 2 | 23 |
| b30-b28 | 16 | 24 |
| b28-b26 | 16 | 25 |
| b26-b24 | 24 | 26 |
| b24-b22 | 16 | 27 |
| b22-b20 | 22 | 28 |
| b20-b18 | 22 | 29 |
| b18-b16 | 6 | 30 |
| b16-b14 | 0 | 31 |
| b14-b12 | 0 | 32 |
| b12-b10 | 0 | 33 |
| b10-b8 | 0 | 34 |
| b8-b6 | 0 | 35 |
| b6-b4 | 0 | 36 |
| b4-b2 | 0 | 37 |
However, when I sort the visual by the SortOrder column, I lose the reference to the rango values on the X-axis.
My goal is to display the rango values on the X-axis, but in the specific order given by the 'SortOrder' column.
How can I achieve this?
This is my current output (notice how in the x axis, the ordering isn't the same as in the table):
And this is my expected output (i need this chart but instead of having the SortOrder in the x axis i need the rango coulmn):
- Anonymous3 years ago
Hi lucastkacz
You can create a measure.
e.g Measure = SELECTEDVALUE('Table'[SortOrder])
Then put it to the tooltip, then select sort by measure and sort ascending.
Output
Best Regards!
Yolo Zhu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
2 Replies
- Idrissshatila
Super User
Hello lucastkacz ,
so you go to the data view then go to this rango column and then click on it anf then click on sort column by and choose the sort column you have.
check this link https://learn.microsoft.com/en-us/power-bi/create-reports/desktop-sort-by-column?tabs=powerbi-desktop
If I answered your question, please mark my post as solution, Appreciate your Kudos 👍
- AnonymousNot applicable
Hi lucastkacz
You can create a measure.
e.g Measure = SELECTEDVALUE('Table'[SortOrder])
Then put it to the tooltip, then select sort by measure and sort ascending.
Output
Best Regards!
Yolo Zhu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.