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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
vat2do
Helper III
Helper III

convert general number to days hours minutes and seconds

Greetings to all,

 

After downloading service now report in excel i receive a random number for the column "business elapsed time" which should be in format of days-hours-minutes-seconds.

Screenshot 2025-01-12 143114.jpg

Is there any way in power bi to convert this random number to days-hours-minutes-seconds format. Thanks in advaced

1 ACCEPTED SOLUTION

Assuming that those numbers are in seconds, try this custom column in the query editor

Duration.From(0) + #duration(0, 0, 0, [Seconds])

Full sample M Code

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjM2MjJRitUBsgyMjUwhLCMLC2Mwy9IACJRiYwE=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Seconds = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Seconds", Int64.Type}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Days", each let 
SecondsInADay = 60 * 60 * 24
in [Seconds]/ SecondsInADay, type number),
    #"Added Custom1" = Table.AddColumn(#"Added Custom", "Duration", each Duration.From(0) + #duration(0, 0, 0, [Seconds]), type duration)
in
    #"Added Custom1"

 

danextian_0-1736682518083.png

Please note that although the data type is duration, it will be loaded as number into the model so the two custom column in the query editor will look the same in the designer.

 

danextian_1-1736682665383.png

You can create a calculated column to format it but please note that the result cannot be summed as it will be a text string.

Duration Time format = 
VAR DayOnly =
    INT ( 'Table'[Duration] )
VAR TimeOnly = 'Table'[Duration] - DayOnly
RETURN
    DayOnly & "."
        & FORMAT ( TimeOnly, "HH:MM:SS" )

danextian_2-1736682830630.png

 

 





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

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


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

View solution in original post

4 REPLIES 4
danextian
Super User
Super User

Hi @vat2do 

What is that elapsed time? Are they in minutes, seconds, hours?





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

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


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

Assuming that those numbers are in seconds, try this custom column in the query editor

Duration.From(0) + #duration(0, 0, 0, [Seconds])

Full sample M Code

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjM2MjJRitUBsgyMjUwhLCMLC2Mwy9IACJRiYwE=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Seconds = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Seconds", Int64.Type}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Days", each let 
SecondsInADay = 60 * 60 * 24
in [Seconds]/ SecondsInADay, type number),
    #"Added Custom1" = Table.AddColumn(#"Added Custom", "Duration", each Duration.From(0) + #duration(0, 0, 0, [Seconds]), type duration)
in
    #"Added Custom1"

 

danextian_0-1736682518083.png

Please note that although the data type is duration, it will be loaded as number into the model so the two custom column in the query editor will look the same in the designer.

 

danextian_1-1736682665383.png

You can create a calculated column to format it but please note that the result cannot be summed as it will be a text string.

Duration Time format = 
VAR DayOnly =
    INT ( 'Table'[Duration] )
VAR TimeOnly = 'Table'[Duration] - DayOnly
RETURN
    DayOnly & "."
        & FORMAT ( TimeOnly, "HH:MM:SS" )

danextian_2-1736682830630.png

 

 





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

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


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

Thanks @danextian for asking,

 

Yes the elapsed time is in "Days Hours Minutes Seconds" format

I did reply to my initial response and assumed that those numbers are in seconds.





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

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


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.