cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
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
Super User II
Super User II

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!

View solution in original post

Super User II
Super User II

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


Connect on LinkedIn

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



* Matt is a Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.

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
secondImage

Happy New Year from Power BI

This is a must watch for a message from Power BI!

December Update

Check it Out!

Click here to read more about the December 2020 Updates!

Community Blog

Check it Out!

Click here to read the latest blog and learn more about contributing to the Power BI blog!

Get Ready for Power BI Dev Camp

Get Ready for Power BI Dev Camp

Mark your calendars and join us for our next Power BI Dev Camp!.

Top Solution Authors
Top Kudoed Authors