Forum Discussion

lucastkacz's avatar
lucastkacz
New Member
3 years ago
Solved

Maintaining Custom Order in Power BI Stacked Column Chart's X-axis

I have a dataset in Power BI structured as:

b76-b740
b74-b720
b72-b708
b70-b6814
b68-b6614
b66-b6420
b64-b6222
b62-b6022
b60-b5830
b58-b5628
b56-b544
b54-b524
b52-b5012
b50-b480
b48-b468
b46-b448
b44-b422
b42-b402
b40-b382
b38-b362
b36-b342
b34-b322
b32-b302
b30-b2816
b28-b2616
b26-b2424
b24-b2216
b22-b2022
b20-b1822
b18-b166
b16-b140
b14-b120
b12-b100
b10-b80
b8-b60
b6-b40
b4-b20

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-b7401
b74-b7202
b72-b7083
b70-b68144
b68-b66145
b66-b64206
b64-b62227
b62-b60228
b60-b58309
b58-b562810
b56-b54411
b54-b52412
b52-b501213
b50-b48014
b48-b46815
b46-b44816
b44-b42217
b42-b40218
b40-b38219
b38-b36220
b36-b34221
b34-b32222
b32-b30223
b30-b281624
b28-b261625
b26-b242426
b24-b221627
b22-b202228
b20-b182229
b18-b16630
b16-b14031
b14-b12032
b12-b10033
b10-b8034
b8-b6035
b6-b4036
b4-b2037

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):

 

  • Anonymous's avatar
    Anonymous
    3 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