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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Anonymous
Not applicable

Total worked Hours (measure)

Hi Experts

 

I am having a nightmare in trying to work out total worked hours based in the sample data for mulitple employees. In the smaple data the total worked hours for the month Nov 23 should be 267.17.00 in hours:minutes:sec

 

The date in the sample data is link to date in my calender table and i get 17:35:00 

 

Sample data

CRMDateDurationContracted/OT
Apples24-Nov-2304:17:00 OVERTM:
Apples23-Nov-2301:00:00 OVERTM:
Apples20-Nov-2301:00:00 OVERTM:
Apples16-Nov-2301:00:00 OVERTM:
Apples13-Nov-2301:00:00 OVERTM:
Apples06-Nov-2301:00:00 OVERTM:
Apples02-Nov-2301:00:00 OVERTM:
Apples20-Nov-2301:00:00 OVERTM:
Apples16-Nov-2301:00:00 OVERTM:
Apples13-Nov-2301:00:00 OVERTM:
Apples06-Nov-2301:00:00 OVERTM:
Apples02-Nov-2301:00:00 OVERTM:
Apples25-Nov-2307:00:00Normal Hours
Apples18-Nov-2307:00:00Normal Hours
Apples11-Nov-2307:00:00Normal Hours
Apples03-Nov-2307:00:00Normal Hours
Apples18-Nov-2307:00:00Normal Hours
Apples11-Nov-2307:00:00Normal Hours
Apples03-Nov-2307:00:00Normal Hours
Apples17-Nov-2304:00:00 OVERTM:
Apples17-Nov-2304:00:00 OVERTM:
Apples27-Nov-2307:30:00Normal Hours
Apples23-Nov-2307:30:00Normal Hours
Apples22-Nov-2307:30:00Normal Hours
Apples21-Nov-2307:30:00Normal Hours
Apples20-Nov-2307:30:00Normal Hours
Apples16-Nov-2307:30:00Normal Hours
Apples15-Nov-2307:30:00Normal Hours
Apples14-Nov-2307:30:00Normal Hours
Apples13-Nov-2307:30:00Normal Hours
Apples09-Nov-2307:30:00Normal Hours
Apples08-Nov-2307:30:00Normal Hours
Apples07-Nov-2307:30:00Normal Hours
Apples06-Nov-2307:30:00Normal Hours
Apples02-Nov-2307:30:00Normal Hours
Apples01-Nov-2307:30:00Normal Hours
Apples20-Nov-2307:30:00Normal Hours
Apples16-Nov-2307:30:00Normal Hours
Apples15-Nov-2307:30:00Normal Hours
Apples14-Nov-2307:30:00Normal Hours
Apples13-Nov-2307:30:00Normal Hours
Apples09-Nov-2307:30:00Normal Hours
Apples08-Nov-2307:30:00Normal Hours
Apples07-Nov-2307:30:00Normal Hours
Apples06-Nov-2307:30:00Normal Hours
Apples02-Nov-2307:30:00Normal Hours
Apples01-Nov-2307:30:00Normal Hours
1 ACCEPTED SOLUTION
v-xuxinyi-msft
Community Support
Community Support

Hi @Anonymous 

You can create a calculated column as follows.

 

Second =
HOUR ( 'Sample'[Duration] ) * 3600
    + MINUTE ( 'Sample'[Duration] ) * 60
    + SECOND ( 'Sample'[Duration] )

 

 

Then create a measure as follows.

 

total =
VAR _TotalSeconds =
    CALCULATE ( SUM ( 'Sample'[Second] ), ALL ( 'Sample' ) )
VAR _Hours =
    INT ( DIVIDE ( _TotalSeconds, 3600, 0 ) )
VAR _Minutes =
    MOD ( DIVIDE ( _TotalSeconds, 60, 0 ), 60 )
VAR _Seconds =
    MOD ( _TotalSeconds, 60 )
RETURN
    _Hours & ":" & _Minutes & ":" & _Seconds

 

 

vxuxinyimsft_0-1702277826649.png

 

Is this the result you expect?

 

Best Regards,

Yuliax

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

1 REPLY 1
v-xuxinyi-msft
Community Support
Community Support

Hi @Anonymous 

You can create a calculated column as follows.

 

Second =
HOUR ( 'Sample'[Duration] ) * 3600
    + MINUTE ( 'Sample'[Duration] ) * 60
    + SECOND ( 'Sample'[Duration] )

 

 

Then create a measure as follows.

 

total =
VAR _TotalSeconds =
    CALCULATE ( SUM ( 'Sample'[Second] ), ALL ( 'Sample' ) )
VAR _Hours =
    INT ( DIVIDE ( _TotalSeconds, 3600, 0 ) )
VAR _Minutes =
    MOD ( DIVIDE ( _TotalSeconds, 60, 0 ), 60 )
VAR _Seconds =
    MOD ( _TotalSeconds, 60 )
RETURN
    _Hours & ":" & _Minutes & ":" & _Seconds

 

 

vxuxinyimsft_0-1702277826649.png

 

Is this the result you expect?

 

Best Regards,

Yuliax

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

 

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.