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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
rmcgrath
Advocate II
Advocate II

Need help sorting X-axis

Trying to sort my X-axis where my values are text.  I needed to show "Week-Day" and so I end up with values like "103-1", "98-2", etc.  The problem I'm having after clicking the three dot menu on the line chart and sorting by "Week-Day", "Ascending" is any of the 100 numbers come right after zero?  I assume because they start with 1?  How could I fix this so they are in the proper order?

 

rmcgrath_0-1749838761646.png

 

 

 

1 ACCEPTED SOLUTION
SamsonTruong
Super User
Super User

Hi @rmcgrath ,

One solution to this is creating a new calculated column for sorting. The DAX calculated column would be as follows:

WeekDaySortOrder = 
VAR WeekNum = VALUE(LEFT('YourTable'[WeekDay], FIND("-", 'YourTable'[WeekDay]) - 1))
VAR DayNum = VALUE(RIGHT('YourTable'[WeekDay], LEN('YourTable'[WeekDay]) - FIND("-", 'YourTable'[WeekDay])))
RETURN WeekNum * 10 + DayNum


This will make a new column that turns your values such as "103-1" to 1031 and "98-2" 982. From here, we will use this new column to sort your original WeekDay column.

In your table view tab, select your WeekDay column. In the top ribbon, click on the sort by column option and select the newly created column. This will sort your original column by the new column.

SamsonTruong_0-1749850116832.png

If this helped, please mark it as the solution so others can benefit too. And if you found it useful, kudos are always appreciated.

Thanks,

Samson

 

Connect with me on LinkedIn

Check out my Blog

Going to the European Microsoft Fabric Community Conference? Check out my Session

 

 

View solution in original post

3 REPLIES 3
SamsonTruong
Super User
Super User

Hi @rmcgrath ,

One solution to this is creating a new calculated column for sorting. The DAX calculated column would be as follows:

WeekDaySortOrder = 
VAR WeekNum = VALUE(LEFT('YourTable'[WeekDay], FIND("-", 'YourTable'[WeekDay]) - 1))
VAR DayNum = VALUE(RIGHT('YourTable'[WeekDay], LEN('YourTable'[WeekDay]) - FIND("-", 'YourTable'[WeekDay])))
RETURN WeekNum * 10 + DayNum


This will make a new column that turns your values such as "103-1" to 1031 and "98-2" 982. From here, we will use this new column to sort your original WeekDay column.

In your table view tab, select your WeekDay column. In the top ribbon, click on the sort by column option and select the newly created column. This will sort your original column by the new column.

SamsonTruong_0-1749850116832.png

If this helped, please mark it as the solution so others can benefit too. And if you found it useful, kudos are always appreciated.

Thanks,

Samson

 

Connect with me on LinkedIn

Check out my Blog

Going to the European Microsoft Fabric Community Conference? Check out my Session

 

 

I love the idea, but it throws an error:  

rmcgrath_0-1749861988845.png

 

Hi @rmcgrath ,

It appears you be might be trying to do this as a measure. The code provided will only work as a calculated column.

 

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors