Forum Discussion

christ7's avatar
christ7
Frequent Visitor
6 years ago
Solved

X Axis Custom sort

Hello,

The chart below displays columns by date (chronologically then alphabetically), yet I need to change this and have tried numerous ways but unable to do so. Is there any way I can cusom sort or create something?

I need it to show:

2018-2019 Pre-season -> 2018-2019 Mid-season -> 2018-2019 End-season

 

Any help is appreciated

Thank you

  • Hi,

     

    The trick to this is to not try to solve your problem in the chart !

     

    The x-Axis must be type categorical (text type field for example) - which your data seems to be.

     

    To have a cusomt order, resort to your data itself.  You will need a reference table that has your x-axis values and a second column (numeric) that is your desired sort order.

     

    The sorting table would look something like this:

     

    Category                                     Position

    2018-2019 Pre-season     1

    2018-2019 Mid-season    2

    2018-2019 End-season    3

     

    Create a reference linking this table to your main data.

     

    Now navigate to your data table where the Category field is, and highlight the column.  In the Modeling Tab, there is an option to 'Sort By Column' and select the 'Position' column from the table above.

     

    Now, in your chart, the default sorting for the Categorical X-Axis uses the rules applied to the field itself - which are now your custom sort for 'Position'.

     

    Regards,

     

    Dean

  • Hi christ7 ,

    As DeanWHall said, you need to create a new table to implement it. 

    Create a new table > manage relationship between tables > sorting new tables order by new column in new table

     

    There is a similar thread that you can reference.

    https://community.powerbi.com/t5/Desktop/Custom-Sorting-in-PowerBI/m-p/128051#M54392

     

    Best Regards,

    Xue Ding

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

3 Replies

  • Hi,

     

    The trick to this is to not try to solve your problem in the chart !

     

    The x-Axis must be type categorical (text type field for example) - which your data seems to be.

     

    To have a cusomt order, resort to your data itself.  You will need a reference table that has your x-axis values and a second column (numeric) that is your desired sort order.

     

    The sorting table would look something like this:

     

    Category                                     Position

    2018-2019 Pre-season     1

    2018-2019 Mid-season    2

    2018-2019 End-season    3

     

    Create a reference linking this table to your main data.

     

    Now navigate to your data table where the Category field is, and highlight the column.  In the Modeling Tab, there is an option to 'Sort By Column' and select the 'Position' column from the table above.

     

    Now, in your chart, the default sorting for the Categorical X-Axis uses the rules applied to the field itself - which are now your custom sort for 'Position'.

     

    Regards,

     

    Dean

    • 22LACMT's avatar
      22LACMT
      Helper III

      How do you disable the auto sort feature on the visual that is overriding my custom sort? 

       

  • v-xuding-msft's avatar
    v-xuding-msft
    Community Support

    Hi christ7 ,

    As DeanWHall said, you need to create a new table to implement it. 

    Create a new table > manage relationship between tables > sorting new tables order by new column in new table

     

    There is a similar thread that you can reference.

    https://community.powerbi.com/t5/Desktop/Custom-Sorting-in-PowerBI/m-p/128051#M54392

     

    Best Regards,

    Xue Ding

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.