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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

Convert Text field to duration assuming 10 hours in a day.

Hello,

 

I am trying to convert an incoming text column in this format - "hh:mm:ss" to a duration column with "dd.hh:mm:ss" format.

 

These are the constraints i need to work with -

 

1. The hours(hh) part of the string exceeds 23 hrs; ex - "239:29:46" (239 hours; 29 min; 46 sec). This will need to be handled - I am currently using - #duration(0, Int64.From(parsed{0}), Int8.From(parsed{1}), Int8.From(parsed{2})) to parse these chunks and convert to type duration.

2. The above formula assumes 24 hours in a day to handle this conversion, so the output will be(for the above case) "9.23:29:46"(approx). However I want to assume only 10 hours in a day, so the output will need to be "23.9:29:46".

 

Is there a way to do this using power query?

 

Any help is much appreciated.

 

Thanks,

-K

1 ACCEPTED SOLUTION
mahoneypat
Microsoft Employee
Microsoft Employee

Here is one way to do it.  Put this formula in the pop-up box when you add a custom column, substituting your column name in place of Column1.

 

let
templist = List.Transform(Text.Split([Column1], ":"), each Number.FromText(_))
in
#duration(Number.RoundDown(templist{0}/10),Number.Mod(templist{0},10), templist{1}, templist{2})

 

If this works for you, please mark it as the solution.  Kudos are appreciated too.  Please let me know if not.

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

3 REPLIES 3
mahoneypat
Microsoft Employee
Microsoft Employee

Here is one way to do it.  Put this formula in the pop-up box when you add a custom column, substituting your column name in place of Column1.

 

let
templist = List.Transform(Text.Split([Column1], ":"), each Number.FromText(_))
in
#duration(Number.RoundDown(templist{0}/10),Number.Mod(templist{0},10), templist{1}, templist{2})

 

If this works for you, please mark it as the solution.  Kudos are appreciated too.  Please let me know if not.

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


Anonymous
Not applicable

Hi @mahoneypat 

 

This seemed to do the trick. Will this also work for 8 hour days if i just switch out the 10's with 8's?

 

 

It should work with 8s too.

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


Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors