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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
littlepatos2
Regular Visitor

Sorting Years and Months in Line Chart

I have a dataset with 2 years of retail transactions and the data includes Month and Year columnhs.  I am trying to create a line chart to show decline in total cost over years and months but i can't get it to sort correctly.

Data 

littlepatos2_0-1715995527214.png

 

1 ACCEPTED SOLUTION
Greg_Deckler
Super User
Super User

@littlepatos2 You will need a numeric Sort By column for your Month, something like MONTH('Table'[Date]) and then set that as your Sort By column for your alphanumeric month name column.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

4 REPLIES 4
mihart
Microsoft Employee
Microsoft Employee

In your semantic model, create a column that creates the correct sort order.  For example, 2401 for January 2024, 2402 for February 2024, etc....  Then use that field instead for your X axis. 

v-jiewu-msft
Community Support
Community Support

Hi @littlepatos2 ,

First of all, many thanks to  for your very quick and effective replies.

I can't open the link.

Based on my testing, please try the following methods:

1.Create the simple table.

vjiewumsft_0-1716186462161.png

2.Select the Date column and choose the sort by values column.

vjiewumsft_1-1716186478512.png

3.The result is shown below.

vjiewumsft_2-1716186484644.png

Best Regards,

Wisdom Wu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Anand24
Super User
Super User

@littlepatos2 ,
Create a new month table with Months and Month Number. Sort Months by the Month number. Connect this table to original date table or whichever table you are pulling fields from on Month. Pull month from this new table into line chart. 

Greg_Deckler
Super User
Super User

@littlepatos2 You will need a numeric Sort By column for your Month, something like MONTH('Table'[Date]) and then set that as your Sort By column for your alphanumeric month name column.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

Check out the November 2024 Power BI update to learn about new features.