Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

Time diff from different rows based on name e day (Hours worked)

Hi there,

 

I have to build a dax measures to calculate the worked time of each employee. The challenge here is that the data is saved by a sequence of input that the employee saves his timesheet in the MS forms.

 

I have the table below:

And I need to build a dax formula for the following requirements:

 

By employee:

  • Hours worked today
  • Hours worked this week
  • Hours Worked from home

 

To achieve this I need the time diff from different rows, however, based on the employee name and the day.

 

Any way to achieve this easily in DAX without the need to change the structure of my table?

 

Thanks in advance.

 

Now the table to make easier the copy and paste

 

IDStart timeEnd TimeNamePlace of workStarting or finishing work?
17/1/21 8:107/1/21 13:01JohnHomeStarting
27/1/21 8:127/1/21 13:10AhbraHomeStarting
37/1/21 8:057/1/21 14:00ElisaHomeStarting
47/1/21 8:137/1/21 15:10ElisaHomeFinishing
57/1/21 8:007/1/21 16:00JohnHomeFinishing
67/1/21 8:457/1/21 13:00AbhraHomeFinishing
77/1/21 8:527/1/21 13:00JohnOfficeStarting
87/1/21 8:487/1/21 13:00ElisaHomeStarting
98/1/21 8:038/1/21 13:20JohnOfficeFinishing
108/1/21 8:468/1/21 13:03ElisaHomeFinishing

 

 

 

 

 

  • Hello fabinishi1207

     

    Try this measure below

     

    TimeWork =

    VAR DATEDIFF = DATEDIFF(MINX(Table,Table[Start time]),MAXX(Table,Table[End Time]),MINUTE)


    return

    DATEDIFF
     
     
    Best Regards

2 Replies

  • Portrek's avatar
    Portrek
    Resolver III

    Hello fabinishi1207

     

    Try this measure below

     

    TimeWork =

    VAR DATEDIFF = DATEDIFF(MINX(Table,Table[Start time]),MAXX(Table,Table[End Time]),MINUTE)


    return

    DATEDIFF
     
     
    Best Regards
    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi Portrek,

       

      Thanks for the feedback but unfortunately it didn't work as expected.