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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
vkandala
Frequent Visitor

convert run_duration (DD: HH: MM: SS) column to Seconds.

Hello,

 

I am trying to convert run_duration (DD: HH: MM: SS)  column to Seconds. 

For example, if Run duration is 1 Day: 1 hour: 1 minute: 1 second I need to convert it to 90061 seconds

 

86400 + 3600 + 60 + 1 = 90061.

 

 

Thanks

1 ACCEPTED SOLUTION
Greg_Deckler
Super User
Super User

Seconds = VAR DurationString = SUBSTITUTE(Durations1[Duration], ":", "|")
VAR Days = PATHITEM(DurationString,1)
VAR Hours = PATHITEM(DurationString,2)
VAR Minutes = PATHITEM(DurationString,3)
VAR Seconds = PATHITEM(DurationString,4)
RETURN Days * 86400 + Hours * 3600 + Minutes * 60 + Seconds


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

2 REPLIES 2
Greg_Deckler
Super User
Super User

Seconds = VAR DurationString = SUBSTITUTE(Durations1[Duration], ":", "|")
VAR Days = PATHITEM(DurationString,1)
VAR Hours = PATHITEM(DurationString,2)
VAR Minutes = PATHITEM(DurationString,3)
VAR Seconds = PATHITEM(DurationString,4)
RETURN Days * 86400 + Hours * 3600 + Minutes * 60 + Seconds


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...


@smoupre wrote:
Seconds = VAR DurationString = SUBSTITUTE(Durations1[Duration], ":", "|")
VAR Days = PATHITEM(DurationString,1)
VAR Hours = PATHITEM(DurationString,2)
VAR Minutes = PATHITEM(DurationString,3)
VAR Seconds = PATHITEM(DurationString,4)
RETURN Days * 86400 + Hours * 3600 + Minutes * 60 + Seconds

@Greg_Deckler

Wow, it is really tricky to use PATHITEM to get the substrings. Awesome work Smiley LOL.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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