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

Next up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now

Reply
kvitnitskiy
Frequent Visitor

Convert text value to long time

Hello comunity.

 I have duration value  in sec(integer),  I use DAX to convert it to time 

Movement Time =
VAR Duration ='Summary table'[Duration(sec)]
VAR Hours =INT ( Duration / 3600)
VAR Minutes =INT ( MOD( Duration - ( Hours * 3600 ),3600 ) / 60)
VAR Seconds =ROUNDUP(MOD ( MOD( Duration - ( Hours * 3600 ),3600 ), 60 ),0)
VAR H =IF ( LEN ( Hours ) = 1,
CONCATENATE ( "0", Hours ),Hours)
VAR M =IF (LEN ( Minutes ) = 1,
CONCATENATE ( "0", Minutes ),Minutes)
VAR S =IF (LEN ( Seconds ) = 1,
CONCATENATE ( "0", Seconds ),Seconds)
RETURN
CONCATENATE (H,CONCATENATE ( ":", CONCATENATE ( M, CONCATENATE ( ":", S ) ) ))
kvitnitskiy_0-1673373993088.png

Then I try appy time format for this column and got error 

 

kvitnitskiy_2-1673374050901.png

So this perfectly works untill my time value less or equall  to 23:59:59.

question - how can I convert duration to time like hhh:nn:mm  and apply time format as well 

1 ACCEPTED SOLUTION
v-jianboli-msft
Community Support
Community Support

Hi @kvitnitskiy ,

 

Power BI doesn't support Duration data type for time over 24 hours.

vjianbolimsft_0-1673404918901.png

 

vjianbolimsft_1-1673404918403.png

 

If you need the time format, you can consider adding an extra column to save the part beyond 24h, or use the Date\Time format to convert the part beyond 24h to days

 

Best Regards,

Jianbo Li

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
ppm1
Solution Sage
Solution Sage

Please see this article for a better way to handle durations like this.

Calculate and Format Durations in DAX – Hoosier BI

Pat

Microsoft Employee
v-jianboli-msft
Community Support
Community Support

Hi @kvitnitskiy ,

 

Power BI doesn't support Duration data type for time over 24 hours.

vjianbolimsft_0-1673404918901.png

 

vjianbolimsft_1-1673404918403.png

 

If you need the time format, you can consider adding an extra column to save the part beyond 24h, or use the Date\Time format to convert the part beyond 24h to days

 

Best Regards,

Jianbo Li

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

amitchandak
Super User
Super User

@kvitnitskiy , You can have a number like

 

1*time(h,m,s) 

 

That will be a fraction of a day . you can multiply with 24 to get hours

 

24*60 to get minutes

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

FabCon and SQLCon Highlights Carousel

FabCon &SQLCon Highlights

Experience the highlights from FabCon & SQLCon, available live and on-demand starting April 14th.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.