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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
redwings00
Helper I
Helper I

Convert Seconds to dd:hh:mm:ss

Hello,

 

I have a column which represents seconds, but I need to now create a metric showing the average in days, hours, minutes and seconds. In the below example, this average of my column is 213955 seconds, which should equal to 2 Days 11 Hours 25 Minutes 55 Seconds. I'm not sure how to get this to show in a Power BI metric. The final output could either be one metric for a card, or separate cards to show the days, hours, minutes, seconds.

Seconds.JPG

 

 

 

 

 

 

 

 

 

 

 

Would someone be able to assist with this? Thank you in advance

 

sample file - pbix file 

1 ACCEPTED SOLUTION
Fowmy
Super User
Super User

@redwings00 

Use the following measure to get the desired result:

New Time = 
var vSeconds=AVERAGE(Sheet1[Seconds])
var vMinutes=int( vSeconds/60)
var vRemainingSeconds=MOD(vSeconds, 60)
var vHours=INT(vMinutes/60)
var vRemainingMinutes=MOD(vMinutes,60)
var vDays=INT(vHours/24)
var vRemainingHours=MOD(vHours,24)
return
  vDays&" Days & "&
  vRemainingHours&" Hours & "&
  vRemainingMinutes&" Minutes & "& 
  ROUND(vRemainingSeconds,0)& " Seconds"

 

Fowmy_0-1606159776973.png

________________________

If my answer was helpful, please consider Accept it as the solution to help the other members find it

Click on the Thumbs-Up icon if you like this reply 🙂

YouTube  LinkedIn

 



Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

View solution in original post

2 REPLIES 2
Fowmy
Super User
Super User

@redwings00 

Use the following measure to get the desired result:

New Time = 
var vSeconds=AVERAGE(Sheet1[Seconds])
var vMinutes=int( vSeconds/60)
var vRemainingSeconds=MOD(vSeconds, 60)
var vHours=INT(vMinutes/60)
var vRemainingMinutes=MOD(vMinutes,60)
var vDays=INT(vHours/24)
var vRemainingHours=MOD(vHours,24)
return
  vDays&" Days & "&
  vRemainingHours&" Hours & "&
  vRemainingMinutes&" Minutes & "& 
  ROUND(vRemainingSeconds,0)& " Seconds"

 

Fowmy_0-1606159776973.png

________________________

If my answer was helpful, please consider Accept it as the solution to help the other members find it

Click on the Thumbs-Up icon if you like this reply 🙂

YouTube  LinkedIn

 



Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

hello Good day, apply the code that comments, and I do not mark error, but in the whole column I add the same result, did not make the calculation for each rowCapture.PNGCapture2.PNGCapture.PNG

Helpful resources

Announcements
Sept PBI Carousel

Power BI Monthly Update - September 2024

Check out the September 2024 Power BI update to learn about new features.

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

Sept NL Carousel

Fabric Community Update - September 2024

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

Top Kudoed Authors