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

Sorting Hours and Minutes

I have a test dataset where I have one date column and two columns with two different time values (hour:minutes) for the same date.

 

If any of those two time columns is selected in a slicer, it gives me a weird date in the slicer. This happens when the column data type is "Time".

 

If I change the column data type to "Text" , I can get the actual time values in the slicer but they are sorted without keeping AM and PM values in mind.

 

For example, time values 7:30 AM, 8:20 AM, 10 AM, and 2 PM will sort like this - 10:00 AM, 2:00 PM, 7:30 AM, 8:20 AM

 

I want them to sort in the correct AM and PM order.

 

Please help.

1 ACCEPTED SOLUTION
v-yulgu-msft
Employee
Employee

Hi @AJ007,


If any of those two time columns is selected in a slicer, it gives me a weird date in the slicer. This happens when the column data type is "Time".

 


What does "a weird date in the slicer" look like? Please show us the screenshot. In my test, the date and time column are both displayed correctly.

 


For example, time values 7:30 AM, 8:20 AM, 10 AM, and 2 PM will sort like this - 10:00 AM, 2:00 PM, 7:30 AM, 8:20 AM

 

I want them to sort in the correct AM and PM order.

 


To reset the sort ordering, please refer to this thread. To create the auxilliary table which is used to sort, please create a blank query in Query Editor mode and paste below code into "Advanced editor".

let
    Source = List.Times(#time(0, 0,0), 1440, #duration(0, 0, 1, 0))
in
    Source

1.PNG

 

Convert the query to table.

2.PNG

 

Change the column type to "Time", add an index column.

3.PNG

 

Best regards,

Yuliana Gu

Community Support Team _ Yuliana Gu
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

1 REPLY 1
v-yulgu-msft
Employee
Employee

Hi @AJ007,


If any of those two time columns is selected in a slicer, it gives me a weird date in the slicer. This happens when the column data type is "Time".

 


What does "a weird date in the slicer" look like? Please show us the screenshot. In my test, the date and time column are both displayed correctly.

 


For example, time values 7:30 AM, 8:20 AM, 10 AM, and 2 PM will sort like this - 10:00 AM, 2:00 PM, 7:30 AM, 8:20 AM

 

I want them to sort in the correct AM and PM order.

 


To reset the sort ordering, please refer to this thread. To create the auxilliary table which is used to sort, please create a blank query in Query Editor mode and paste below code into "Advanced editor".

let
    Source = List.Times(#time(0, 0,0), 1440, #duration(0, 0, 1, 0))
in
    Source

1.PNG

 

Convert the query to table.

2.PNG

 

Change the column type to "Time", add an index column.

3.PNG

 

Best regards,

Yuliana Gu

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

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.