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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
vblake
Frequent Visitor

year not sorting correctly on x axis in line chart

Hi all,

I've come across an issue with a dates table function and relating it to my data table. I've created the dates table using an M function that i got from a udemy course video. I've linked it with a table of data i want to analyse. I want to create a line chart with year and the x axis and count of products from each manufacturer on the y axis. For some reason the year isn't sorting in chronological order. It seems like the year sorts fine when i put it as the legend but not on the x axis. I've checked the table relationships and they look fine, I've checked the data type of the columns i'm joining and they're both date type. I checked to see if i had duplicates in either table and i don't. I'm stumped as to why it's not working. I've included some screen shots of what I've done.

This is the chart with 2014 in the wrong position

Here the year looks like it's sorting fine

This the relationship between the tables

The data type of the columns that are joined are the same

 

1 ACCEPTED SOLUTION

Thanks everyone for your suggestions, I checked the x-axis and it was categorical and not continuous. It wouldn't let me change it to continuous and so i had a look at the data type of the year variable and it was set as text and not numeric. I've changed it and it's working fine now. Thanks for your help!

View solution in original post

5 REPLIES 5
jdbuchanan71
Super User
Super User

With the chart selected, go to the format pane.  Under the X axis, is the type set to Categorical instead of Continuous?

chartsort.jpg

Thanks everyone for your suggestions, I checked the x-axis and it was categorical and not continuous. It wouldn't let me change it to continuous and so i had a look at the data type of the year variable and it was set as text and not numeric. I've changed it and it's working fine now. Thanks for your help!

tex628
Community Champion
Community Champion

Weird indeed, the line chart is sorted on year decending/acending? 


Connect on LinkedIn
MattAllington
Community Champion
Community Champion

Weird. My best guess is there are spaces before and or after some of the columns, changing the sort order. 



* Matt is an 8 times Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.
I will not give you bad advice, even if you unknowingly ask for it.

Thanks for the suggestion guys. I’ll give it a go when i’m back in the office on Monday and let you know if it worked

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors