Forum Discussion

JonSwed's avatar
JonSwed
Icon for Advocate II rankAdvocate II
5 years ago
Solved

Changing seconds into a hh:mm:ss duration

This is doing my head in. 

I want to report seconds in a table as a hh:mm:ss duration rather than just ss.

I've been able to get this far (using the instructions here: https://efficiency365.com/2018/08/31/power-bi-seconds-to-duration/)

But I cannot get this data to appear in table in the desired format. Any suggestions gratefully accepted.
Thanks!

  • Anonymous's avatar
    Anonymous
    5 years ago

    Hi JonSwed ,

     

    The result you displayed is actually correct, because your seconds column is a decimal number, which seems a little strange.As shown in the figure below, both 666 seconds and 666.14 seconds are converted into 11 minutes, and the result is correct. If you don't want to display decimals, you can use rounding to round up and then convert. 

     

    #duration(0,0,0,Number.Round([Sec2]))

     

     

    You can check more details from here.

     

     

     

    Best Regards,

    Stephen Tao

     

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

3 Replies

  • CNENFRNL's avatar
    CNENFRNL
    Icon for Community Champion rankCommunity Champion

    Hi, JonSwed , you might want to truncate milliseconds from [avg_time_on_page] column by adding new column using this formula

    #duration(0,0,0,Number.RoundDown([avg_time_on_page]))

     

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi JonSwed ,

     

    The result you displayed is actually correct, because your seconds column is a decimal number, which seems a little strange.As shown in the figure below, both 666 seconds and 666.14 seconds are converted into 11 minutes, and the result is correct. If you don't want to display decimals, you can use rounding to round up and then convert. 

     

    #duration(0,0,0,Number.Round([Sec2]))

     

     

    You can check more details from here.

     

     

     

    Best Regards,

    Stephen Tao

     

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

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi JonSwed ,

    Could you tell me if your problem has been solved?
    If it is, kindly Accept it as the solution. More people will benefit from it.
    Or you are still confused about it, please provide me with more details about your table and your problem or share me with your pbix file from your Onedrive for Business.


    Best Regards,
    Stephen Tao