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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
JustinDoh1
Post Prodigy
Post Prodigy

How to sort by Hour which is created in text

I am sharing my Pbix here.

 

I am trying to sort bar graph based on hour.

For instance, it will start from 12:00 AM --> 1:00 AM ..... 10:00 PM --> 11:00 PM.

 

Currently, it is sorted in the count.

JustinDoh1_0-1631748662308.png

 

Currently, the "Hour" column is created using text data type.

JustinDoh1_2-1631748056006.png

 

 

And "HourOrig" field (data type = Whole number) is created using this date/time field ("IncidentData").

JustinDoh1_3-1631748201076.png

 

JustinDoh1_4-1631748412051.png

 

How do I go about doing this?

The reason I created "Hour" as text is to show ".. PM" or ".. AM".

 

But now, how do I sort properly (12:00 AM --> 11:00 PM)?

 

Thanks in advance.

 

 

 

 

1 ACCEPTED SOLUTION

Hi @JustinDoh1 ,

 

The type of column Hour1 is Time, so there is no option to sort. You can use column Hour as the axis of the stacked bar chart, and then sort column Hour based on column HourOrig.

 

vkkfmsft_0-1632116568642.png              vkkfmsft_1-1632116609506.png

 

If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.

Best Regards,
Winniz

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

View solution in original post

3 REPLIES 3
CNENFRNL
Community Champion
Community Champion

Screenshot 2021-09-16 021038.png

it's, in essence, of type number; thus, no worries about sorting.


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

@CNENFRNL  Thanks for help.

How do I sort from 12:00 AM --> 11:00 PM?

It is currently sorting in other way.

JustinDoh1_0-1631812708119.png

One thing I noticed was, there is no option to select "Sort descending, Sort ascedning nor Sort by" from this visual.

JustinDoh1_0-1631815608215.png

 

Sharing my updated file here (just in case).

 

Hi @JustinDoh1 ,

 

The type of column Hour1 is Time, so there is no option to sort. You can use column Hour as the axis of the stacked bar chart, and then sort column Hour based on column HourOrig.

 

vkkfmsft_0-1632116568642.png              vkkfmsft_1-1632116609506.png

 

If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.

Best Regards,
Winniz

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

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