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

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
Anonymous
Not applicable

How to convert hrs in string to duration

I am trying to convert a column type string to duration and tried doing my own research to do it, but I have failed. 

 

This is the column I am needing to convert. 

 

PwBIDummy_0-1656520587412.png

 

This is the M code I am using. 

 

 

 

= Table.TransformColumns(#"Changed Type",{"Resolution Time (in Hrs)",each 
let txt=_,
h=Number.From( Text.Start(txt,2)),
mm=Number.From( Text.Middle(txt,3,2)),
ss=Number.From( Text.End(txt,2)),
dd=Number.IntegerDivide(h,24),
hh=Number.Mod(h,24)
in 
#duration(dd,hh,mm,ss),
type duration
}
)

 

 

 

 

Here are the results 

PwBIDummy_1-1656520699545.png

I believe I am getting the errors because of the 3 digit hours, but I do not understand or know how to do a range for the start.text or if that is even how I should approach this. 

 

Please help! 

1 REPLY 1
HotChilli
Super User
Super User

You can use Text.BeforeDelimiter,  .AfterDeli... , .BetweenDelim... for this.

--

A slightly easier way might be to Split the column on ":" and then add a custom column to construct the desired result , for example, #duration(0,1stCol, 2ndCol, 3rdCol) 

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors