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
Mann
Resolver III
Resolver III

Custom Sorting the x-axis with time value

Hi All,

I created a simple line graph with Time values in X axis and Measure dropped to value area as shown.
X axis: Column "Time" coming from Table A having time values like (08:00 AM, 08:05 AM, 08:10 AM... for 24 hours round the clock for multiple dates)
Y axis: Simple Measure (Sum of some column in Table A)

As-Is.PNG

By defualt Power BI takes sorting from 12AM to 12AM. I need to show it from 8AM to 8AM.

 

I followed these steps:

1) Created a sort order column "Sort" in table A in Power Query such that: For rows having time value: 8:00 AM is given "1" and 8:05AM is given "2" and so on.

2) When I sort column "Time" with "Sort" I get a straight line in line graph. X axis still show values from 12:00 AM to 12:00 AM.

 

As-Is Issue.PNG

How can I achieve the sorting from 8:00 AM to 8:00AM (24hours)?

Please advice?

1 ACCEPTED SOLUTION

Hi Parry,

Thanks for the reply. If I make x axis categorical then it extends the length of x axis which is not the requirement. So instead of using time value on x-axis, I used date time column and used a time slicer. Everytime user selects any date or date range graphs changes accordingly but keeps continuous x axis.

View solution in original post

9 REPLIES 9
v-piga-msft
Resident Rockstar
Resident Rockstar

Hi @Mann,

 

Please have a try if you change the type of the X axis to be categorical.

 

In addition, if it is convenient, could you share your data sample which could reproduce your scenario so that we can copy and test.

 

Best  Regards,

Cherry

Community Support Team _ Cherry Gao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thanks Cherry for reaching out.

 

I have shared the test file link in my post. Categorical won't help because x-axis is having data values for every 5 min for 24 hours. It will make this axis long. I am trying to achieve this using continuous only.

Hi Guys,

 

Just checking in if this is something which we can't achieve in Power BI? Please let me know what you think?

 

Anonymous
Not applicable

see if this is what you had in mind:

 Custom Sort for Time Chart.png

Custom Sort for Time.png

 

Key here is use the the Movement Hour from yoru Order table in the chart, be sure to sort that column  by your sort column in that table, and keep the formatting as text.  When switched to a time it defaults to 12:00:00 for some reason.  

@Mann I looked at your pbix file and here is what you need to do to make it works:

 

- Sort "Movement Hour" in order tabe by sort order.

- drop "Movement Hour" on x-axis and application_id from main table on values

- on format page, change "type" of x-axis to "categorical" instead of "continuous"

 

and that will do it.

 

 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Hi Parry,

Thanks for the reply. If I make x axis categorical then it extends the length of x axis which is not the requirement. So instead of using time value on x-axis, I used date time column and used a time slicer. Everytime user selects any date or date range graphs changes accordingly but keeps continuous x axis.

Hi @Mann,

 

It seems that you have find a workaround. Please always accept the replies making sense as solution to your question so that people who may have the same question can get the solution directly.

 

Best Regards,

Cherry

Community Support Team _ Cherry Gao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
parry2k
Super User
Super User

@Mann you are taking right approach by adding sort column and then sorting your time colum with "sort" column, it is expected to work. Can you share you pbix by chance to further look into it?



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Hi Parry,

 

Thanks for connecting on this. Sorry couldn't reply on this yersterday.

I have created a Test.pbix file and placed it here Test.PBIX. It also contains two sample files I am using as a source to this pbix file.

 

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.