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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

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
PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors
Top Kudoed Authors