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
Anonymous
Not applicable

Time sorting

Hello!  I am working on a project, and I need my time to be in standard time (not military time).  I think I got this coded, but when I go to sort my graph, it doesn't sort by 1am - 11pm.... Attached is my code and screenshots of my data.

 

Thanks in advance!

 

Hour_real = FORMAT('public view_transactions'[Time], "hh:00 AMPM")                  ####I want it to just show the head of the hour
 
nattiej101_0-1618518339709.pngnattiej101_1-1618518357157.png

 

1 ACCEPTED SOLUTION
DataZoe
Microsoft Employee
Microsoft Employee

@Anonymous Instead of making it text, you can make it a time format pushed to the hour, then format it how you please, and it will then sort appropriately.

 

TIME function (DAX) - DAX | Microsoft Docs

Time_Hour = TIME(hour([Time]),0,0)

Then in the ribbon or in the modeling tab (in modelling you can do custom formats!) you can pick the format you want it to display as. 

DataZoe_1-1618520674793.png

 

You can get the X-Axis to show each by changing it to "Categorical" too:

 

DataZoe_3-1618520969920.png

 

Respectfully,
Zoe Douglas (DataZoe)



Follow me on LinkedIn at https://www.linkedin.com/in/zoedouglas-data
See my reports and blog at https://www.datazoepowerbi.com/

View solution in original post

2 REPLIES 2
AlB
Community Champion
Community Champion

Hi @Anonymous 

Try this

Hour_Real = 
VAR aux_ = 1/24
RETURN
aux_*HOUR(Table1[Time])

converting the calculated column to type Time

 

SU18_powerbi_badge

Please accept the solution when done and consider giving a thumbs up if posts are helpful. 

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

 

DataZoe
Microsoft Employee
Microsoft Employee

@Anonymous Instead of making it text, you can make it a time format pushed to the hour, then format it how you please, and it will then sort appropriately.

 

TIME function (DAX) - DAX | Microsoft Docs

Time_Hour = TIME(hour([Time]),0,0)

Then in the ribbon or in the modeling tab (in modelling you can do custom formats!) you can pick the format you want it to display as. 

DataZoe_1-1618520674793.png

 

You can get the X-Axis to show each by changing it to "Categorical" too:

 

DataZoe_3-1618520969920.png

 

Respectfully,
Zoe Douglas (DataZoe)



Follow me on LinkedIn at https://www.linkedin.com/in/zoedouglas-data
See my reports and blog at https://www.datazoepowerbi.com/

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.

Top Solution Authors