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

Next up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now

Reply
DrNesr
Frequent Visitor

Sort month names by their number in X axis of line chart

I have a line chart visual that displaying monthly temperature.

The temperature values are stored in a table with a column [M] which is the integer month number, from 1 to 12.

When I plot them I got something like this

2017-03-20_9-17-59.png

As you see, I have the numbers in X-Axis, however, I want to display Month Names instead, e.g. {Jan, Feb, ... , Dec}

I have created a table with two columns, one for months numbers, and the other for names, as suggested by this post, and I followed what they suggested by sorting by column, (I made a relationship between [M] and the month number) but unfortunately it fails, as this what I got!

2017-03-20_9-36-08.png

As you see, the chart sorts the months on unknown criteria, neither by month numbers, nor by month names alphabetically, but they are almost in descending order by value of temperature!

 

Please help my drawing this graph sorting x-axis labels by month numbers instead of this.

 

Thanks in advance.

1 ACCEPTED SOLUTION
Phil_Seamark
Microsoft Employee
Microsoft Employee

Hi @DrNesr,

 

The default sort order for text based fields is alphabetic.  So normally you need a numeric column alongside this that you can use the "Sort by column" feature.

 

In your case it seems something different.  It looks like it's almost sorting highest to lowest.

 

In the top right hand corner of your visual there is the ... elipsis.  In there you can set a sort order.  Can you please check to see what that is currently set to?

 

sort by.png


To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

View solution in original post

4 REPLIES 4
Phil_Seamark
Microsoft Employee
Microsoft Employee

Hi @DrNesr,

 

The default sort order for text based fields is alphabetic.  So normally you need a numeric column alongside this that you can use the "Sort by column" feature.

 

In your case it seems something different.  It looks like it's almost sorting highest to lowest.

 

In the top right hand corner of your visual there is the ... elipsis.  In there you can set a sort order.  Can you please check to see what that is currently set to?

 

sort by.png


To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

You are awesome @Phil_Seamark,

Thank you very much for this solution.

I checked the dots you mentioned, I found the following 

 

2017-03-20_10-11-50.png

 

Then I clicked the first item (Sort by M_Name

 

I got the following

 

2017-03-20_10-14-34.png

But it was sorted from December to Jauary, I clicked again on the Z-A icon next to the ffirst item as shown

 

Finally it is solved.

 

2017-03-20_10-12-22.png

 

Thanks a lot.

Cool, looks fantastic!


To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

Anonymous
Not applicable

Hi Phil,

If I have an dynamic X axis say If i select Daily its should chnage to Day level, Monthly then Month Level. So far it works fine if I am on daily but moment I click on weekly the month names are sorted alphabatically. So I cerated another small table to sort with Month Names and their Ids as 1,2,3, for Jan, Feb, Mar and so on and put sorting on Month ID but still not working.

 

My X Axis formula is like 

SortedXAxis = if(Period[SelectedPeriod]="Monthly",InventoryReporting[MonthName],if(Period[SelectedPeriod]="Weekly",format(InventoryReporting[WEEK_END_DATE],"MM/DD/YYYY"),format(InventoryReporting[Snapshot Date],"MM/DD/YYYY")))

 

where when I click on Monthly in filter below it gives me data but MOnth Name is sorted alphabatically as below whiel I want to sort it by its sequence. This is bit different than usual

 

MonthCapture.JPG

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.