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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
Josef
Helper I
Helper I

Duration more than 24 hours - transform duration column to DD:HH:MM:SS format

 

Hi guys,

 

I have a CSV fil with a duration column in HH:MM:SS fotmat. When I try to change the column type to 'Duartion' one value gives an error, because the value is larger than 24 hours and the standard duration format is HH:MM:SS (and does not contains days). Does someone know how to 'enlarge' the duration column and add 'days', so the format will be DD:HH:MM:SS (al hours >24 have to be converted to a day)? 

 

Many thanks in advance. 

 

Duration.jpg

1 ACCEPTED SOLUTION

Hi  @Josef ,

 

No need to go to the advance editor. Go to the last step of yur query add a custom column and copy paste the code that I send in the previous post:

 

duration.pngBe aware that twhere there is [Duration] you should place the name of the column you want to convert I have place Duration based on the image you shared.


Regards

Miguel Félix


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

Proud to be a Super User!

Check out my blog: Power BI em Português





View solution in original post

4 REPLIES 4
MFelix
Super User
Super User

Hi @Josef ,

 

This as to do with the parsing of the hours and time functions on the query editor

 

You need to add a column with the following code:

let
    DurationFromYourText = (text as text) as duration => let
        Split = Text.Split(text, ":"),
        AsNumbers = List.Transform(Split, Number.FromText),
        Duration = #duration(0, AsNumbers{0}, AsNumbers{1}, AsNumbers{2})
    in
        Duration,
    Invoked = DurationFromYourText([Duration])
in
    Invoked

Should work as expected.

 

This formula comes from the post:

https://stackoverflow.com/questions/38907024/power-query-parsing-hhmmss-durations-that-are-greater-t...


Regards

Miguel Félix


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

Proud to be a Super User!

Check out my blog: Power BI em Português





@MFelix thanks alot for your reply.

 

Do you mean I have to add this code in the Advanced Power Query Editor?

I tried to insert it in the current steps, but I'm not able to get it right. 

 

At the moment it looks like this:

APQE.jpg

Could you please help me out to inset the code in the right way? It would be appreciated a lot.

 

Hi  @Josef ,

 

No need to go to the advance editor. Go to the last step of yur query add a custom column and copy paste the code that I send in the previous post:

 

duration.pngBe aware that twhere there is [Duration] you should place the name of the column you want to convert I have place Duration based on the image you shared.


Regards

Miguel Félix


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

Proud to be a Super User!

Check out my blog: Power BI em Português





@MFelix Amazing! Many thank this did the job 🙂

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 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.