Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

X-Axis Not Sorting in Categorical Order

My x-axis in the chart is going in a random order. I imagine this is due to it being stored as text and because of the hyphen, is there a way around this issue, so that it does 17-2017, 18-2018, 19-2019, 20-2020, 20-2021, 21-2021? 

 

Thanks!

 

powerbi help.PNG

1 ACCEPTED SOLUTION
VasTg
Memorable Member
Memorable Member

@Anonymous 

Refer to this document..

https://docs.microsoft.com/en-us/power-bi/desktop-sort-by-column

 

You have to create an index column and use that as SORT BY column to your category.

 

There are tons of post in the forum for SORT BY..

 

If it helps mark it as a solution
Kudos are nice too

Connect on LinkedIn

View solution in original post

3 REPLIES 3
v-lili6-msft
Community Support
Community Support

hi  @Anonymous 

For your case, you could just add Year-weeknum column that format is 2017-17,2018-18,2019-19,2020-20,2021-20, 2021-21.

Then selected weeknum-year column(17-2017, 18-2018, 19-2019, 20-2020, 20-2021, 21-2021), set sort by column with Year-weeknum column.

https://docs.microsoft.com/en-us/power-bi/desktop-sort-by-column

https://radacad.com/sort-by-column-in-power-bi

 

Regards,

Lin

Community Support Team _ Lin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
jmalone
Resolver III
Resolver III

You can add a new column to give you the desired sort order. This new column will be a number, not a text.

 

Creating the sort column in the Query Editor, you can use this formula:

( Number.From( Text.Start([Text Column], 2) ) * 10000 ) + Number.From( Text.End([Text Column],4) )

 

Where [Text Column] is the name of your existing column.

 

After loading the data to your model, sort your original column by this new, numerical column. There is a button in the ribbon called "sort by column"

2020-02-27 13_34_59-CDC WONDER Data - Power BI Desktop.png

VasTg
Memorable Member
Memorable Member

@Anonymous 

Refer to this document..

https://docs.microsoft.com/en-us/power-bi/desktop-sort-by-column

 

You have to create an index column and use that as SORT BY column to your category.

 

There are tons of post in the forum for SORT BY..

 

If it helps mark it as a solution
Kudos are nice too

Connect on LinkedIn

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.