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

Change a decimal number to hours & minutes

Hi

 

I am trying to work out how much CPD each staff member. I have imported trhe data as a decimal figure and used a simple measure to change this to a total hours as below:

 

Measure 2 = CALCULATE( SUM( 'Completed CPD (2)'[Duration (Hours) copy]) * 24)

 

This give me the result as 0.25, 139.0, 16.75, 5.50 etc. Can this be changed so that the format is 0:15, 139:00, 16:45 and 5:30? 

 

I have tried the following:

 

sumx('Completed CPD (2)', hour('Completed CPD (2)'[Duration (Hours) copy])) + TRUNC(sumx('Completed CPD (2)', MINUTE('Completed CPD (2)'[Duration (Hours) copy]))/60)  & ":" & mod(sumx('Completed CPD (2)', MINUTE('Completed CPD (2)'[Duration (Hours) copy])), 60)

 

This works for any hours below 24 hours but when the time is 45 hours it shows it as 21:00 (i.e. deducting the first 24 hours).

 

Any help would be really appreciated.

 

Thanks

 

Holly 

1 ACCEPTED SOLUTION
v-cherch-msft
Employee
Employee

Hi @Anonymous

 

You may refer to below measure:

Format =
VAR a =
    ( MAX ( Table[Column1] ) - TRUNC ( MAX ( Table[Column1] ), 0 ) )
        * 60
VAR b =
    INT ( MAX ( Table[Column1] ) )
RETURN
    CONCATENATE ( b, CONCATENATE ( ":", a ) )

1.png

 

Regards,

Cherie

Community Support Team _ Cherie Chen
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

3 REPLIES 3
v-cherch-msft
Employee
Employee

Hi @Anonymous

 

You may refer to below measure:

Format =
VAR a =
    ( MAX ( Table[Column1] ) - TRUNC ( MAX ( Table[Column1] ), 0 ) )
        * 60
VAR b =
    INT ( MAX ( Table[Column1] ) )
RETURN
    CONCATENATE ( b, CONCATENATE ( ":", a ) )

1.png

 

Regards,

Cherie

Community Support Team _ Cherie Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

This works well in solving my similar problem but now i get a table value that has several decimal places to the seconds value?

I have tried to look at format options but this is not available to me for the measure.

Can you help?

 

Min_sec Table.jpg

Greg_Deckler
Super User
Super User

Check out this post:

https://community.powerbi.com/t5/Community-Blog/Aggregating-Duration-Time/ba-p/22486

 


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