cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
KarenFingerhut
Helper III
Helper III

Convert Hours to Days and Minutes

Hi there 

 

I'm trying to convert a duration total to Days, Hours and Minutes.

 

So for instance someone works 7 hours a day and over the course of a month has worked 560 hours. Im trying to covert 560 hours to X days, x hours, x minutes.

 

I just cant seem to do this and i'd be very grateful if someone could help me with this.

 

Many thanks

Karen

1 ACCEPTED SOLUTION

I see I made a mistake while converting the hours, also I didn't consider that your working day is 7 hours... please try this, it should work:

OverTime =
VAR OverTimeHours = [OverTimeHoursMeasure]
VAR Days = INT ( WorkingHours / 7 )
VAR Hours = INT ( WorkingHours - Days * 7 )
VAR Minutes = ROUND ( MOD ( WorkingHours, 1 )* 60 , 0)
RETURN
Days & " Days " & Hours & " Hours " & Minutes & " Minutes"

 

View solution in original post

4 REPLIES 4
KarenFingerhut
Helper III
Helper III

Hi there

 

Thank you for getting back to me. Unfortunately, it doesnt quite work. Here's my result using your formula . Format 2 is your formula and Duration (h) is the number of hours they've done. So for instance Garden, Duration (h) =  32.50. So really they've worked 4 days 4 hours. Can you help with this please.

 

Thank you

Karen

KarenFingerhut_0-1627805647838.png

 

I see I made a mistake while converting the hours, also I didn't consider that your working day is 7 hours... please try this, it should work:

OverTime =
VAR OverTimeHours = [OverTimeHoursMeasure]
VAR Days = INT ( WorkingHours / 7 )
VAR Hours = INT ( WorkingHours - Days * 7 )
VAR Minutes = ROUND ( MOD ( WorkingHours, 1 )* 60 , 0)
RETURN
Days & " Days " & Hours & " Hours " & Minutes & " Minutes"

 

View solution in original post

Thats brilliant thank you. Works a treat.

Kind regards

Karen

Mohammad_Refaei
Solution Specialist
Solution Specialist

Try this (replace [OverTimeHoursMeasure] with the correct measure name):

 

 

OverTime =
VAR OverTimeHours = [OverTimeHoursMeasure]
VAR Days = INT ( WorkingHours / 24 )
VAR Hours = INT ( WorkingHours - INT ( WorkingHours / 24 ) )
VAR Minutes = ROUND ( MOD ( WorkingHours, 1 )* 60 , 0)
RETURN
Days & " Days " & Hours & " Hours " & Minutes & " Minutes"

 

 

Helpful resources

Announcements
PBI_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Get Ready for Power BI Dev Camp

Microsoft named a Leader in The Forrester Wave

Microsoft received the highest score of any vendor in both the strategy and current offering categories.

Get Ready for Power BI Dev Camp

Power BI Dev Camp - September 30th, 2021

Mark your calendars and join us for our next Power BI Dev Camp!

PowerPlatform 768x460.png

Microsoft Learn

Check out our new Discover Your Career Path blog post series and get all the details.