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
Anonymous
Not applicable

Hour convert

Hey guys, I am using the following code to only produce hours from two different columns: hours and minutes. If the minute is over 30, then i need to round it up to the following hour. I am using the following code(below) and it works fine. However, I one of the times that I have is 24 52 minutes and it gives me a value of 1. When it should 25. Any ideas how to fix that?

Rounded Time =

VAR T = TIME('Avg By Daykrauti'[Trukmė Prastova Radviliškis Convertkrauti], 'Avg By Daykrauti'[Trukmė Prastova Radviliškis Convertkrauti 2],0) RETURN
HOUR(
IF( MINUTE(T) > 30,
MROUND(T, 1/24 ),
HOUR(T)/24
)
)
2 ACCEPTED SOLUTIONS
PhilipTreacy
Super User
Super User

Hi @Anonymous 

That is how TIME() works, please refer https://docs.microsoft.com/en-us/dax/time-function-dax

If you pass it a value of 25 for hours that will be converted to 1.

If you want to show hour values greater than 23 then don't use TIME(), just use the text value for the hours.

Phil


If I answered your question please mark my post as the solution.
If my answer helped solve your problem, give it a kudos by clicking on the Thumbs Up.



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


View solution in original post

v-shex-msft
Community Support
Community Support

Hi @Anonymous,

I think you need to use the time function instead, hour function only used to extract the hour part from time or DateTime values.

BTW, you can also take a look at the following blog about time duration value conversion and aggregate if it helps.

Aggregating Duration Time 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

3 REPLIES 3
v-shex-msft
Community Support
Community Support

Hi @Anonymous,

I think you need to use the time function instead, hour function only used to extract the hour part from time or DateTime values.

BTW, you can also take a look at the following blog about time duration value conversion and aggregate if it helps.

Aggregating Duration Time 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.
PhilipTreacy
Super User
Super User

Hi @Anonymous 

That is how TIME() works, please refer https://docs.microsoft.com/en-us/dax/time-function-dax

If you pass it a value of 25 for hours that will be converted to 1.

If you want to show hour values greater than 23 then don't use TIME(), just use the text value for the hours.

Phil


If I answered your question please mark my post as the solution.
If my answer helped solve your problem, give it a kudos by clicking on the Thumbs Up.



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


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.

Top Solution Authors