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
bdehning
Post Prodigy
Post Prodigy

24 HOUR Data and Closet to the Hour

I had a Time Column which I used to convert a specific military time to the nearest hour using a Custom Column.    I used the following

 

=Time.From( Number.Round( Number.From( [Time of Incident] ) * 24 ) / 24 )

 

I got one error when one time was 11:45 PM but everytning else worked.   

 

How do I get POWER BI to use show 24:00 and not show and error?

13 REPLIES 13
ryan_mayu
Super User
Super User

@bdehning 

I don't think we have 24:00, does that showed 00:00, 0-23 are 24  numbers and represent 24 hours.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




I get rows from 00:00 all the way to 23:00.  There must be way to represent 24:00 when time falls between 11:30 pm and 12 AM?

@bdehning 

you can try this, but the output is not time type

try Time.From( Number.Round( Number.From( [Time of Incident] ) * 24 ) / 24 ) 
otherwise "24:00:00"

1.PNG





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




I can get the otherwise "24:00:00" to work at the end of my fomula.  It keeps saying Token Eof expected.   

@bdehning 

could you pls provide the error screenshot?





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Custom Column.PNG

you missed try.

 

try Time.From( Number.Round( Number.From( [Time of Incident] ) * 24 ) / 24 ) 
otherwise "24:00:00"

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




It ran but after going back to Power and checking clustered bar chat it reverted times back to AM and PM and I lost rows like 00:00 because it showed 12:00 am.

 

Do I need a new custom column once I get the 24:00 to show up to get the 00:00, 01:00, 02:00 I am looking for??

@bdehning 

it should not change because the output is text not time type.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




I am still playing with this.  This is an issue with times that fall on  :30:00.  Most as expected round up to the next higher hour but not all.  8:30:00 PM went to 8:00:00 and not 9:00:00 as expected.  4:30:00 AM when to 4:00:00 AM and not 5:00:00 AM.  What do I need to do to get all time with :30:00 to go up to the next hour?

@bdehning 

have you tried to change round to rounddown?

Number.RoundDown - PowerQuery M | Microsoft Docs





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Same thing   what am I missing?Custom Column.PNG

pls add the letter "try" in the formula

= try Time.From( Number.Round( Number.From( [Time of Incident] ) * 24 ) / 24 )
otherwise "24:00:00"





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




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.