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

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

Top Solution Authors