Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago

Changing decimal number into Duration

I have a table with a Start and Finish time I have created a calculated column which subtracts Finish time from start time to give me a duration. The issue I'm having is the format in which the Duration is displayed in desk top. 

 

My Start and Finish times are in the follow format (DD/MM/YYYY  HH:MM:SS).  After the Calculation in the query editor the result is shown as a duration format. When pushed into desktop its then changed to a decimal number. I tired keeping the results as text - that didn't work.

 

M Query CalculationQuery Editor View           Desktop View

 

 

I have seen the duration post by Greg_Deckler and itsfantastic - I just can't get them to work as my Core time column isn't in seconds. Any assistance would be greatly appricated.

 

Thanks

Dobby 

8 Replies

  • mussaenda's avatar
    mussaenda
    Community Champion

    hi Anonymous ,

     

    Use

    Duration.TotalSeconds([TT_Finished] - [TT_Started])

    so your duration will be in seconds then you can follow the post from Greg_Deckler 

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi mussaenda

       

      Thanks for getting back to me! Unfortuantly that didn't work! I got an error where some of the Finished dates return blanks. 

       

       

      I tried to use the Try  Otherwise function. But this just returned the "otherwise" value for all rows.

      • Greg_Deckler's avatar
        Greg_Deckler
        Community Champion

        Anonymous  - It looks like you are getting back a value that is essentially the decimal portion of a day (24 hours). In DAX, you could get that duration in seconds using the following:

         

        Column = ([Finished] - [Started]) * 1. * 24 * 60 * 60

        So, Finished - Started and you multiply by 1. to get a decimal value. You then multiply this by 24 to get the number of hours, 60 to get the number of minutes and then 60 again to get the number of seconds.

  • Icey's avatar
    Icey
    Community Support

    Hi Anonymous ,

    Based on my knowledge, Power BI doesn't support to display Duration type in Power BI Report View as in Power Query.

    You can vote this idea to make it come soon. 

    If you must display the duration time in the report view, there is one workround. You can copy the column and set it to text format and place it on the Tooltip. You can refer to this post: Time Duration and Time Graph Plotting.

     

    Best Regards,
    Icey

     

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

  • Icey's avatar
    Icey
    Community Support

    Hi Anonymous ,

     

    Is this problem sloved?
     
    If it is sloved, please always accept the replies making sense as solution to your question so that people who may have the same question can get the solution directly.
     
    If not, please let me know.
     
    Best Regards
    Icey
    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi Icey

       

      This is still ongoing unfortunantly!  when I tired to use Gregs Dax code I'm getting a insuffient RAM message, My laptop has 32GB and Corei7 8th Gen Processor. 

       

      When I get the issues sorted I'll mark the soultion!

       

      Thanks 

      Dobby

      • Icey's avatar
        Icey
        Community Support

        Hi Anonymous ,

         

        Based on my knowledge, Power BI doesn't support to display Duration type in Power BI Report View as in Power Query.

        You can vote this idea to make it come soon. 

        If you must display the duration time in the report view, there is one workround. You can copy the column and set it to text format and place it on the Tooltip. You can refer to this post: Time Duration and Time Graph Plotting.

         

        Best Regards,
        Icey

         

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