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
mik618
Helper I
Helper I

Measure to calculate time worked

Hi There, 

 

I'm looking to try and calculate a measure to show how mant hours & Minutes a staff member worked per day. 

 

Staff work on appointments that have a start date and time, and an end date and time, so I can calculate the total time per appointment.

 

the problem I'm having it that the appointments overlap, as staff can see up to 10 people at a time, so in one day the staffs table might look like this;

 

  startendtotal hours
staffMemberAappointment11pm2pm1
staffMemberAappointment23pm5pm2
staffMemberAappointment34pm6pm2
staffMemberAappointment47pm8pm1
     
   total hours worked5

 

I can't figure out how to only add up hours and minutes the staff had appointments in total

 

any help would be greatly appreciated 

 

Thanks 

1 ACCEPTED SOLUTION

Hi @mik618 ,

 

I've updated the fileDownload PBIX 

 

Ricardo



Did I answer your question? Mark my post as a solution!

Proud to be a Super User!



View solution in original post

9 REPLIES 9
jstorm
Resolver III
Resolver III

You could use a CALCULATE function with MIN() and MAX() to determine start and end times for the employee's day then simply find the difference.

EX.

CALCULATE(
    MAX( [End] ) -

    MIN( [Start] ),

    [Filter1]

)

HI @jstorm 

 

Thanks, but the problem with that is that there are gaps in the day where the staff won't be wokring and I don't want to include this time

camargos88
Community Champion
Community Champion

Hi @mik618 ,

 

I've created this file: Download PBIX 

 

It creates the ranges for your appointments, so you can calculate without overlaps.

 

If you consider it as a solution, please mark as a solution and kudos.

Ricardo



Did I answer your question? Mark my post as a solution!

Proud to be a Super User!



Thanks @camargos88 for this, 

 

The only problem (my fault for simplifying the example I gave!) is that appointments can be a matter of minutes, rather than hours, so really i need to count minutes worked, and later convert to total hours and minutes,

 

Thanks for your help

Hi @mik618 ,

 

Can you provide some data as example ?

 

Ricardo



Did I answer your question? Mark my post as a solution!

Proud to be a Super User!



Thanks @camargos88 

 

for example a snip of the staff table might look like this;

 

StaffAppointmentStartEnd
Staff1Appointment11.15pm2.10pm
Staff1Appointment23pm5.15pm
Staff1Appointment34pm5.30pm
Staff1Appointment47pm8pm
Staff2Appointment19.15am4pm
Staff2Appointment29am2pm

Hi @mik618 ,

 

I've updated the fileDownload PBIX 

 

Ricardo



Did I answer your question? Mark my post as a solution!

Proud to be a Super User!



Hi @camargos88 

 

This looks great! thanks so much for your help I think this will do exactly what I need!

 

Thanks 

Greg_Deckler
Super User
Super User

I wonder if something like Open Tickets might help. Have to think it through though.

https://community.powerbi.com/t5/Quick-Measures-Gallery/Open-Tickets/m-p/409364#M147

 

 


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