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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

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 CalculationM Query CalculationQuery Editor ViewQuery Editor View           Desktop ViewDesktop 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 8
Icey
Community Support
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
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
Community Support
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
Community Support
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.

mussaenda
Super User
Super User

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

 

Error.PNGQuery Error.PNG

 

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

Hi @Anonymous ,

 

2019_10_08_08_44_58_Window.png

As you can see, I used an If Else for the null then it's okay.

 

Then in Dax, I transformed it to duration time format which I also found here in the forum.

Core Time_Seconds Measure = SUM('Table'[Core Time_Seconds])

 

Duration Format Time_Employee Measure = 
 VAR hours = 
    ROUNDDOWN ( [Core Time_Seconds Measure] / 3600, 0 )
VAR minutes =
    ROUNDDOWN ( MOD ( [Core Time_Seconds Measure] , 3600 ) / 60, 0 )
VAR seconds =
    INT ( MOD ( [Core Time_Seconds Measure] , 60 ) )
RETURN
        FORMAT(hours,"00") 
        & ":"
        & FORMAT(minutes, "00")
        & ":"
        & FORMAT(seconds, "00")

2019_10_08_09_29_31_Untitled_Power_BI_Desktop.png

 

 

 

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


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

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.