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
foxb3692
Helper I
Helper I

Sort by 24-Hour, label by 12-Hour

Greetings,

I have a Line and Stacked Column Chart visual that is oh so close to what the user wants, but not quite.

The desired X-Axis Sort is Ascending 24-Hour Time, but the desired X-Axis labels are 12-Hour AM/PM time. 

I have a TimeDimension query with both an "Hour" field, formatted with leading Zero, and a calculated column 

Hour AM/PM = FORMAT(TimeDimFall[Time],"H AM/PM").
Using "Hour" as the X-Axis produces the correct sort:
2021-02-10 (1).png
 
 
 
 
 
The user doesn't want to see hour "13", they want to see the label "1 PM"
Using Hour AM/PM in the visual lists "1 AM" first then "1 PM" next:
2021-02-10 (2).png 
 
 
 
 
 
How do I get the correct sort with the desired X-Axis labels?
 
1 ACCEPTED SOLUTION
MattAllington
Community Champion
Community Champion

Add the label column to the axis. Click on the label column in the fields list and select "sort by column" and use the 24 hour column for sorting. 



* Matt is an 8 times Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.
I will not give you bad advice, even if you unknowingly ask for it.

View solution in original post

2 REPLIES 2
MattAllington
Community Champion
Community Champion

Add the label column to the axis. Click on the label column in the fields list and select "sort by column" and use the 24 hour column for sorting. 



* Matt is an 8 times Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.
I will not give you bad advice, even if you unknowingly ask for it.

Brilliant! I had to walk through the steps a couple of times, but I got it.

Thank you @MattAllington !

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.