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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
ac10304
Frequent Visitor

Re-ordering the x-axis values - "Sort By" not working

I have a chart where the x-axis values are showing as:
0-3 months, 10-12 months, 4-6 months, 7-9 months (see picture below) 
and i want them to be in ascending order. i am sorting by "months open" and have it selected by "Sort Ascending"

 

bichart.png

 

This is the grouping i have for the months and this is what is being sorted:

 

groups.png

 

Not sure why the "10-12" months group shows between 0-3 and 4-6, and I've searched other forum posts to try their solutions but nothing is working for me. 
Any help will be greatly appreciated!

Thank you.

1 ACCEPTED SOLUTION

Make a calculated column that specifies the group, then put that group on the X-axis.  You should be able to put the extra space that will help with sorting.

 

Group = 

 SWITCH( TRUE(), Age <= 3, " 0-3 Months", Age > 3 && Age <= 6, " 4-6 Months", ...

 

 

Alternatively to the extra space, you calculate the group in a column and also create a dimension table with the same groups.  Put a field on the new table that indicates the sort order, and you can use the "Sort by Column" functionality (on the Modeling tab) to indicate the order of the groups.  Something like

 

Group   Sort Order

0-3 Months   1

4-6 Months   2

 

 

etc

View solution in original post

6 REPLIES 6
ac10304
Frequent Visitor

any other ideas/tips/advice?

Make a calculated column that specifies the group, then put that group on the X-axis.  You should be able to put the extra space that will help with sorting.

 

Group = 

 SWITCH( TRUE(), Age <= 3, " 0-3 Months", Age > 3 && Age <= 6, " 4-6 Months", ...

 

 

Alternatively to the extra space, you calculate the group in a column and also create a dimension table with the same groups.  Put a field on the new table that indicates the sort order, and you can use the "Sort by Column" functionality (on the Modeling tab) to indicate the order of the groups.  Something like

 

Group   Sort Order

0-3 Months   1

4-6 Months   2

 

 

etc

your post helped me figure out the solution, which i found in this post.

 

https://community.powerbi.com/t5/Desktop/Custom-Sorting-in-PowerBI/td-p/126534

 

the solution was posted by @v-haibl-msft so thank you both for helping me figure this out!

see correct order below:

 

correctorder1015.png

 

thanks again!

dedelman_clng
Community Champion
Community Champion

All of your group names are text strings - they are no longer treated as numbers. 

 

You can put a space character at the beginning of your group names that contain numbers less than 10, and then they should sort correctly (space comes alphabetically before 0).

 

Hope this helps

David

Just tried adding a space @ the beginning of the group names (0-3, 4-6, 7-9) and the space character wasn't saved in the grouping name. 

so instead of (space)0-3 it was just 0-3. 

Apologies - I didn't test it, I just assumed you would be able to do it (you can do it in the source data, but not in the groups).  You may need to look at calculating groups in a way different from the built-in group functionality in PowerBI (calculated column, etc).

Helpful resources

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

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.