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
Anonymous
Not applicable

Convert An Int Field to Time Format

Hi,

 

I want to convert an INT feild(Time Spent On Calls In secs ) in a matrix table to hh:mm:ss format ,how to do that ?Capture.PNG

 
3 ACCEPTED SOLUTIONS
dax
Community Support
Community Support

Hi @Anonymous , 

If you want to convert second to hh:mm:ss, I think you could refer to above links to convert it. If you are using measure, you also could try below to achieve this goal

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

 

Best Regards,
Zoe Zhi

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

Jimmy801
Community Champion
Community Champion

Hello @Anonymous 

 

if you need a solution in Power Query, this concept would work out

let
    Source = #table({"Time_Spent_On_Calls"}, {{"15292"}, {"16163"}}),
    ChangedType = Table.TransformColumnTypes(Source,{{"Time_Spent_On_Calls", Int64.Type}}),
    AddDays = Table.AddColumn(ChangedType, "GetDays", each [Time_Spent_On_Calls]/60/60/24, type number ),
    AddedDuration = Table.AddColumn(AddDays, "Duration", each Duration.From([GetDays])),
    AddedHHMMSS = Table.AddColumn(AddedDuration, "hh:mm:ss", each Text.From(Number.RoundDown (Duration.TotalHours([Custom])))&":"&Text.From(Duration.Minutes([Custom]))&":"&Text.From(Duration.Seconds([Custom])))
in
    AddedHHMMSS

 

Copy paste this code to the advanced editor in a new blank query to see how the solution works. If this solution fits your need, copy and past a part of it and implement it in your query

If this post helps or solves your problem, please mark it as solution (to help other users find useful content and to acknowledge the work of users that helped you)
Kudoes are nice too

Have fun

Jimmy

View solution in original post

4 REPLIES 4
Jimmy801
Community Champion
Community Champion

Hello @Anonymous 

 

if you need a solution in Power Query, this concept would work out

let
    Source = #table({"Time_Spent_On_Calls"}, {{"15292"}, {"16163"}}),
    ChangedType = Table.TransformColumnTypes(Source,{{"Time_Spent_On_Calls", Int64.Type}}),
    AddDays = Table.AddColumn(ChangedType, "GetDays", each [Time_Spent_On_Calls]/60/60/24, type number ),
    AddedDuration = Table.AddColumn(AddDays, "Duration", each Duration.From([GetDays])),
    AddedHHMMSS = Table.AddColumn(AddedDuration, "hh:mm:ss", each Text.From(Number.RoundDown (Duration.TotalHours([Custom])))&":"&Text.From(Duration.Minutes([Custom]))&":"&Text.From(Duration.Seconds([Custom])))
in
    AddedHHMMSS

 

Copy paste this code to the advanced editor in a new blank query to see how the solution works. If this solution fits your need, copy and past a part of it and implement it in your query

If this post helps or solves your problem, please mark it as solution (to help other users find useful content and to acknowledge the work of users that helped you)
Kudoes are nice too

Have fun

Jimmy

Anonymous
Not applicable

 my problem is i have duration in seconds column in a table and i am doing the sum of the column per user name and showing it in the matrix table , but my client wants this to show it as hh:mm:ss format , which i am not able to do it 

dax
Community Support
Community Support

Hi @Anonymous , 

If you want to convert second to hh:mm:ss, I think you could refer to above links to convert it. If you are using measure, you also could try below to achieve this goal

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

 

Best Regards,
Zoe Zhi

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

Helpful resources

Announcements
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.