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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Deeh
New Member

Help - Converted decimal to hour BUT minutes and seconds are above 60

Guys, I need your help.

 

I work with hours over 24 and I used in excel a column formatted in hour/37:50:55. In excel I created another column and converted it to decimal "cell*24 called worked hour DEC and I am doing my calculations in power BI on top of this column.

help 1.png

 

I created a formula in DAX and then formatted it as 00:00:00 which is working on the card and on the line and column graphs, however, the minutes and seconds are above 59. The hours are apparently correct and I need them to be accumulated over 24 hours but the minutes and seconds cannot exceed 59.

 

I also need to do the same calculation and the same types of graphs for downtime and the same thing is happening. With these same measurements I also need to calculate MTTR "MTTR = DIVIDE([Downtime],SUM(Base[Qty of failures]),0)" and MTBR "MTBF = DIVIDE([Worked hours]-[Downtime],[Failures],0)" and I'm also having problems with seconds and minutes over 24h. Can anyone help me identify where I'm going wrong? Please help me, I've tried every possible way I could find on the internet but it always goes wrong. This dax is the only one that works with all the options, the others give errors when converting text into numbers.

 

DAX 

Worked hours =

var vhour = INT(SUM(Base[Hours worked DEC]))
var vminute = INT((SUM(Base[Hours worked DEC]) - vhour) * 60)
VAR vsecond = ROUND(((sum  (Base[Hours worked DEC]) - vhour ) * 60 - vminute ) * 60,0)

var SS = IF(vsecond=0, vsecond & 0, vsecond)

var MM = FORMAT(vminute,"00")

var HH = FORMAT(vhour,"00")

RETURN
VALUE(HH&MM&SS)

 

0db8946f-5da3-482e-81ea-505b2fd72fb4.png

help 01.pngHELP.jpgSem título 33.jpg

1 ACCEPTED SOLUTION
aj1973
Community Champion
Community Champion

Ok Please follow these steps:

Open Power Query and Split column Hours Worked by delimiter "Colon" to get this

aj1973_0-1703631341517.png

Rename columns

aj1973_1-1703631379152.png

Add custom column

aj1973_2-1703631440135.png

Change type of the custom column to numbers

aj1973_3-1703631507348.png

 

Apply your formula or mine(as you like)

aj1973_4-1703631579310.png

Here is mine if you want

Total Working =
var _seconds = SUM('Working hours'[Total in Seconds])
var _minutes = INT(_seconds / 60)
var _RemainingSeconds = MOD(_seconds, 60)
var _Hours = INT(_minutes / 60)
var _RemainingMinutes = MOD(_minutes, 60)
var _Days = INT(_Hours / 24)
var _RemainingHours = MOD(_Hours, 24)
return
_Days & " D : " &
_RemainingHours & " H : " &
_RemainingMinutes & " M : " &
_RemainingSeconds & " S  "
 
let me know

 

Regards
Amine Jerbi

If I answered your question, please mark this thread as accepted
and you can follow me on
My Website, LinkedIn and Facebook

View solution in original post

4 REPLIES 4
ryan_mayu
Super User
Super User

@Deeh 

maybe you can change the last coding to 

RETURN
HH&":"&MM&":"&SS




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

Proud to be a Super User!




Deeh
New Member

Hello, I'm a beginner in Power BI and I don't know how to convert hours to decimals or decimals to hours in this way. To convert hours to decimals in excel I created the column =cell*24 and in PBI I'm using this column to do the calculations, so they are already in decimals. but I don't know how to convert from decimals to seconds if that's what you meant. I did exactly what you wrote and it came up with a crazy big number.total duration.png

aj1973
Community Champion
Community Champion

Ok Please follow these steps:

Open Power Query and Split column Hours Worked by delimiter "Colon" to get this

aj1973_0-1703631341517.png

Rename columns

aj1973_1-1703631379152.png

Add custom column

aj1973_2-1703631440135.png

Change type of the custom column to numbers

aj1973_3-1703631507348.png

 

Apply your formula or mine(as you like)

aj1973_4-1703631579310.png

Here is mine if you want

Total Working =
var _seconds = SUM('Working hours'[Total in Seconds])
var _minutes = INT(_seconds / 60)
var _RemainingSeconds = MOD(_seconds, 60)
var _Hours = INT(_minutes / 60)
var _RemainingMinutes = MOD(_minutes, 60)
var _Days = INT(_Hours / 24)
var _RemainingHours = MOD(_Hours, 24)
return
_Days & " D : " &
_RemainingHours & " H : " &
_RemainingMinutes & " M : " &
_RemainingSeconds & " S  "
 
let me know

 

Regards
Amine Jerbi

If I answered your question, please mark this thread as accepted
and you can follow me on
My Website, LinkedIn and Facebook

aj1973
Community Champion
Community Champion

Hi @Deeh 

Before starting using your formula you need to convert Hours Worked  to seconds then

aj1973_0-1703612403890.png

 

Better use Power Query to convert it in seconds.

Regards
Amine Jerbi

If I answered your question, please mark this thread as accepted
and you can follow me on
My Website, LinkedIn and Facebook

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.