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
juan-botero
Regular Visitor

Hours to working days

Hello everyone!

 

I have a measure which shows how long will a project take in hours. These hours are not formatted as time, they are just numbers. I want to convert that number to working days with a 9 hour per day work.

 

I will appreciate all your help.

 

Kind regards,

Juan

2 ACCEPTED SOLUTIONS
TomMartens
Super User
Super User

Hey,

I'm not sure how the result should look like, but I'm sure that need the functions INT() and MOD(). Assuming that there are 21 hours INT(21/9) results to 2, the number of days. MOD(21,9) results to 3, the number of remaining hours.

Here is the link to the MOD function: https://msdn.microsoft.com/en-us/query-bi/dax/mod-function-dax

You also have to consider to encapsulate both functions I mentioned above in the expression part of SUMX to get the correct result for totals.

If you need more help, then provide sample data. Upload a file to onedrive or dropbox and share the link.

Regards,
Tom


Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

View solution in original post

v-frfei-msft
Community Support
Community Support

Hi @juan-botero,

 

Based on your description, I made an sample here. At first, I created a measure to get the working hours.

 

 

diffhours = DATEDIFF(MAX(Table2[start date]),MAX(Table2[end date]),HOUR)

 

Then we can get working days by the formula as below.

 

Measure1 = IF([diffhours]<9,"0 day" & [diffhours], INT([diffhours]/9) & " day(s) " & MOD([diffhours],9) &" hour(s)")

Capture.PNG

 

For more details, please check the pbix as attached. If it doesn't meet your requirement, kindly share you sample data or your pbix to me.

 

https://www.dropbox.com/s/dh2d4s0de30e5ih/working%20days.pbix?dl=0

 

Regards,

Frank

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

View solution in original post

4 REPLIES 4
v-frfei-msft
Community Support
Community Support

Hi @juan-botero,

 

Based on your description, I made an sample here. At first, I created a measure to get the working hours.

 

 

diffhours = DATEDIFF(MAX(Table2[start date]),MAX(Table2[end date]),HOUR)

 

Then we can get working days by the formula as below.

 

Measure1 = IF([diffhours]<9,"0 day" & [diffhours], INT([diffhours]/9) & " day(s) " & MOD([diffhours],9) &" hour(s)")

Capture.PNG

 

For more details, please check the pbix as attached. If it doesn't meet your requirement, kindly share you sample data or your pbix to me.

 

https://www.dropbox.com/s/dh2d4s0de30e5ih/working%20days.pbix?dl=0

 

Regards,

Frank

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

Thanks Frank, exactly what I needed!

TomMartens
Super User
Super User

Hey,

I'm not sure how the result should look like, but I'm sure that need the functions INT() and MOD(). Assuming that there are 21 hours INT(21/9) results to 2, the number of days. MOD(21,9) results to 3, the number of remaining hours.

Here is the link to the MOD function: https://msdn.microsoft.com/en-us/query-bi/dax/mod-function-dax

You also have to consider to encapsulate both functions I mentioned above in the expression part of SUMX to get the correct result for totals.

If you need more help, then provide sample data. Upload a file to onedrive or dropbox and share the link.

Regards,
Tom


Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

Hi Tom.

 

INT and MOD functions were exactly what I needed, but, as stated in the following post, I used the function IF instead of SUMX. Thanks a lot for your help!

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.