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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
gauravkumar16
Frequent Visitor

Sorting months spanning two years

@Ritaf1983

 

Screenshot 2023-10-08 134101.png

 

I have months starting from Sep2022 to Sep2023. In line chart, they are not appearing chronologically.

Can anyone pls help how to achieve this.

 

6 REPLIES 6
gauravkumar16
Frequent Visitor

Thanks @DOLEARY85 for your replies.

 

Actually I found out that data type for a calculated column was not correct.

I had created a column with month and year e.g. Sep 2022.

It's datatype should be date. It was text in my case.

Once datatype is changed the line chart sorts itself chronologically.

 

DOLEARY85
Resident Rockstar
Resident Rockstar

Hi,

 

you'll need to sort your column by something that runs in the correct order.

 

Select your month-year column and use 'sort by column' on the 'column tools' tool bar then select the field to sort by. If you don;t have anything you could create something simple like a number that follows the month and year in your calendat table. e.g 

 

Column = value(month('Calendar'[Date])&year('Calendar'[Date]))

 

If I answered your question, please mark my post as solution, Appreciate your Kudos 👍

 

Thanks Doleary58 for replying.

 

I have a column as Month and Year in format "YYMMMM" so Sep 2022 is written as 092022.

Screenshot 2023-10-08 140458.png

 

Now in line chart i have put this field in X-axis. Also, I have sorted the data by this column as you explained.

 

But still it is not sorted chronologically whether you do ASC or DESC.

 

Screenshot 2023-10-08 140647_1.pngScreenshot 2023-10-08 140713_2.png

 

Isn't it?

 

Can you check that your month year serial column is numeric?

Thanks for pointing that out.

Now I have made it numeric but still it is not chronological.

Screenshot 2023-10-08 164420.png

You may need to make the numeric column to sort by something different, try creating a calculated column that ranks the date in order:

 

1. RankColumn = RANKX(ALL(Table), Table[Date Column], , ASC, Dense)
2. Select the field you want to be ordered (yearmonthserial)
3. Select column tools, sort by column, then the rank column you just made

DOLEARY85_1-1696780298443.png

4. if the chart doesn't update automatically, remove the yearmonthserial field and readd it.

 

If I answered your question, please mark my post as solution, Appreciate your Kudos 👍

 

 
 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.