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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
bdehning
Post Prodigy
Post Prodigy

Custom Column

I have a Custom Column with the following:

 

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

 

I need to add code to account for time that is 11:30 PM and later as it creates an error as it can not do 24:00.

 

Also I want to add,  if null then No Entry.  

 

Can I do that in Custom or can I convert Custom to Conditional Column?

1 ACCEPTED SOLUTION

That was close.

 

I had to use 

 

Time.From(if Number.Round( Number.From( [Time of Incident] ) * 24.01 ) / 24=1 then 0.0 else Number.Round( Number.From( [Time of Incident] ) * 24.01 ) / 24)

 

This allowed time under :30 to go back to the hour.  

View solution in original post

6 REPLIES 6
amitchandak
Super User
Super User

@bdehning , If data type is time, Then 24 hours display is just a display property

or you can try like

Time(hour([Time]), Minute([Time]), 0)

 

If this does not help
Can you share sample data and sample output in table format?

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

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

 

I get the following,  How do I account for the error because of the time that is 11:46:00?

7a6e2701-d91d-4733-be99-0b572ad7e7b7.png

Hi, @bdehning 

 

You can try the following methods.

Time.From(if Number.Round( Number.From( [Time of Incident] ) * 24 ) / 24=1 then 0.5 else Number.Round( Number.From( [Time of Incident] ) * 24 ) / 24)

vzhangti_3-1656488604035.png

vzhangti_2-1656488592221.png

Is this the result you expect?

 

Best Regards,

Community Support Team _Charlotte

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

It's really close.  How do I get any time with :30 to round up to the next hour?   

 

It currently rounds down

Hi, @bdehning 

 

You can try changing Number.Round to Number.RoundUp.

Time.From(if Number.RoundUp( Number.From( [Time of Incident] ) * 24 ) / 24=1 then 0.5 else Number.RoundUp( Number.From( [Time of Incident] ) * 24 ) / 24)

vzhangti_1-1657246786594.png

Does this meet your desired outcome?

 

Best Regards,

Community Support Team _Charlotte

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

That was close.

 

I had to use 

 

Time.From(if Number.Round( Number.From( [Time of Incident] ) * 24.01 ) / 24=1 then 0.0 else Number.Round( Number.From( [Time of Incident] ) * 24.01 ) / 24)

 

This allowed time under :30 to go back to the hour.  

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.