cancel
Showing results 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

Regular Visitor

Convert seconds column into duration column hh:mm:ss.ss (needs hundredths of a second in output)

I am trying to convert a column that contains a time in seconds into a duration that includes hundreds of a second

eg

Convert 242.5 secs into  00:04:02.05

Regards

1 ACCEPTED SOLUTION
Employee

```Column 2 =
VAR hours =
ROUNDDOWN ( [Column1] / 3600, 0 )
VAR minutes =
ROUNDDOWN ( MOD ( [Column1], 3600 ) / 60, 0 )
VAR seconds =
INT ( MOD ( [Column1], 60 ) )
VAR milliseconds =
round(MOD ( [Column1], 1 ) * 100,0)
RETURN
FORMAT(hours,"00") & ":"
& FORMAT(minutes, "00")
& ":"
& FORMAT(seconds, "00")
& "."
& FORMAT(milliseconds, "00")```

Best Regards,

Dale

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
6 REPLIES 6
Employee

Seems there isn't a built-in support of such format. Please vote up this idea here. The workaround could be as below.

```Column 2 =
VAR hours =
ROUNDDOWN ( [Column1] / 3600, 0 )
VAR minutes =
ROUNDDOWN ( MOD ( [Column1], 3600 ) / 60, 0 )
VAR seconds =
INT ( MOD ( [Column1], 60 ) )
VAR milliseconds =
ROUND ( MOD ( [Column1], 1 ) * 100, 0 )
RETURN
hours & ":"
& minutes
& ":"
& seconds
& "."
& milliseconds```

Best Regards,

Dale

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Regular Visitor

Thanks Dale for the help,

How would you force each number to be of two digits length ?  4 minutes 2.17 secs would be 00:04:02.17

Regards

Employee

```Column 2 =
VAR hours =
ROUNDDOWN ( [Column1] / 3600, 0 )
VAR minutes =
ROUNDDOWN ( MOD ( [Column1], 3600 ) / 60, 0 )
VAR seconds =
INT ( MOD ( [Column1], 60 ) )
VAR milliseconds =
round(MOD ( [Column1], 1 ) * 100,0)
RETURN
FORMAT(hours,"00") & ":"
& FORMAT(minutes, "00")
& ":"
& FORMAT(seconds, "00")
& "."
& FORMAT(milliseconds, "00")```

Best Regards,

Dale

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Regular Visitor

Thank you so much Dale this is great.  I assume there is no way that this can be forced into a Duration format though ?

Employee

There is a Duration type for the Power Query while there isn't a Duration type for DAX. That's why I suggested you vote up the idea.

Best Regards,

Dale

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Regular Visitor

Thank you dale

Announcements

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Monthly Update - June 2024

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

Fabric Community Update - June 2024

Get the latest Fabric updates from Build 2024, key Skills Challenge voucher deadlines, top blogs, forum posts, and product ideas.

Top Solution Authors
Top Kudoed Authors