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

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.

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
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.