cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
vblake Frequent Visitor
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

Accepted Solutions
vblake Frequent Visitor
Frequent Visitor

Re: year not sorting correctly on x axis in line chart

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
Super User

Re: year not sorting correctly on x axis in line chart

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.
tex628 New Contributor
New Contributor

Re: year not sorting correctly on x axis in line chart

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

vblake Frequent Visitor
Frequent Visitor

Re: year not sorting correctly on x axis in line chart

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
Super User
Super User

Re: year not sorting correctly on x axis in line chart

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

chartsort.jpg

vblake Frequent Visitor
Frequent Visitor

Re: year not sorting correctly on x axis in line chart

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

Helpful resources

Announcements
New Topics Started Badges Coming

New Topics Started Badges Coming

We're releasing new versions of the badge that everyone's talking about. ;) Check your inbox for notifications.

MBAS 2020

Save the new date (and location)!

Our business applications community is growing—so we needed a different venue, resulting in a new date and location. See you there!

Difinity Conference

Difinity Conference

The largest Power BI, Power Platform, and Data conference in New Zealand

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

Top Solution Authors
Top Kudoed Authors (Last 30 Days)