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
rosscortb
Post Patron
Post Patron

calculate decimal hrs and mins

Hello,hrs and mins.PNG

 

I know there is many links on this but seems to be based on having seconds.

 

I have decimal hrs and seconds but as you can see the sum is incorrect as it should be 92 hrs 15 secs.

Any ideas on how to get this please?

Thanks
Ross

1 ACCEPTED SOLUTION
mahoneypat
Employee
Employee

This is one way to do this (not directly) with a custom column in the query editor with this formula. Place this in the pop-up box when you add a custom column. The "let" only stores the duration in a variable so that it is not calculated twice.

let dur - #duration(0, Number.RoundDown([Annual Leave],0)+Number.RoundDown([Annual Leave Carryover],0), Number.Round(100*(Number.Mod([Annual Leave],1) + Number.Mod([Annual Leave Carryover],1)),0),0) en Duration.Days(dur)*24 + Duration.Hours(dur)

Best regards

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


View solution in original post

8 REPLIES 8
rosscortb
Post Patron
Post Patron

@v-kelly-msft I did click the accept as solution yellow button yestereday but looks like you have to click the three dots and do it from there..

v-kelly-msft
Community Support
Community Support

Hi  @rosscortb ,

 

Create a column as below:

 

Column = 
var _wholenumber1=TRUNC('Table'[Column1])
var _wholenumber2=TRUNC('Table'[Column2])
var _totalminutes=('Table'[Column1]-_wholenumber1+'Table'[Column2]-_wholenumber2)*100
Return
TRUNC(_totalminutes/60)+_wholenumber1+_wholenumber2+(_totalminutes-60)/100

 

And you will see:

Screenshot 2020-11-09 171116.png

If you directly add them up ,it will return as a result of sum up,so you need to separate hours and minutes then add them up.

 

For the related .pbix file,pls see attached.

 

Best Regards,
Kelly

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

mahoneypat
Employee
Employee

This is one way to do this (not directly) with a custom column in the query editor with this formula. Place this in the pop-up box when you add a custom column. The "let" only stores the duration in a variable so that it is not calculated twice.

let dur - #duration(0, Number.RoundDown([Annual Leave],0)+Number.RoundDown([Annual Leave Carryover],0), Number.Round(100*(Number.Mod([Annual Leave],1) + Number.Mod([Annual Leave Carryover],1)),0),0) en Duration.Days(dur)*24 + Duration.Hours(dur)

Best regards

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


thanks @mahoneypat

thanks for help everyone

Hi  @rosscortb ,

 

So your issue is solved,right?If so,could you pls mark the reply as answered to close it?

I believe more people will benefit from your post.

 

Best Regards,
Kelly

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

amitchandak
Super User
Super User

@rosscortb , is it 91 hours 58 minute + 15 Min then it will 92 hours 13 Min . can you explain

@amitchandak sorry yes typo error

91 hrs 58 mins plus 15 mins = 92 hrs 13 mins

mussaenda
Super User
Super User

Hi @rosscortb ,

 

Then is it possible on your side to round the annual leave decimal hrs then add it to the Carryover column?

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.