Forum Discussion

James_Galis1's avatar
James_Galis1
Helper II
3 years ago
Solved

Calculate hours

Hello All   Would appreciate some assistance with the following.   I have 1 table with employee schedules that shows the time and date of visits I wish to have a calculated column that looks at ...
  • Ritaf1983's avatar
    Ritaf1983
    3 years ago

    Hi James_Galis1 again:)
    If i understans you correctly after yoour response then something like that:
    (I have done it in 3 steps to make it easier to follow , you can combine to 1)
    1. Calculate for every employee first start time for each day :

    First_Start_time_Employee = CALCULATE(MIN('Table'[Start Time]), ALLEXCEPT('Table','Table'[Employee  Name],'Table'[Visit Date])
    )

    2. Do the same with last end time:

    Last_End Time_time_Employee = CALCULATE(MAX('Table'[End Time]), ALLEXCEPT('Table','Table'[Employee  Name],'Table'[Visit Date])
    )
    3. Calculate difference between them in minuts and divide by 60 :
    Hours_Availble = DATEDIFF('Table'[First_Start_time_Employee],'Table'[Last_End Time_time_Employee],MINUTE)/60

    Link to the sample file 

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

  • Ritaf1983's avatar
    Ritaf1983
    3 years ago

    Hi James_Galis1 
    You can summarize your total worked hours with the following:

    Hours worked = CALCULATE(sumx('Table',DATEDIFF('Table'[Start Time],'Table'[End Time],MINUTE))/60, ALLEXCEPT('Table','Table'[Employee  Name],'Table'[Visit Date])
    )

     

    and then calculate the delta:

    Hours_Diff = [Hours_Availble]-[Hours worked]

    I updated a sample file with those new columns.

    link is still Here 
    If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly