Forum Discussion
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
| ID | Start time | End Time | Name | Place of work | Starting or finishing work? |
| 1 | 7/1/21 8:10 | 7/1/21 13:01 | John | Home | Starting |
| 2 | 7/1/21 8:12 | 7/1/21 13:10 | Ahbra | Home | Starting |
| 3 | 7/1/21 8:05 | 7/1/21 14:00 | Elisa | Home | Starting |
| 4 | 7/1/21 8:13 | 7/1/21 15:10 | Elisa | Home | Finishing |
| 5 | 7/1/21 8:00 | 7/1/21 16:00 | John | Home | Finishing |
| 6 | 7/1/21 8:45 | 7/1/21 13:00 | Abhra | Home | Finishing |
| 7 | 7/1/21 8:52 | 7/1/21 13:00 | John | Office | Starting |
| 8 | 7/1/21 8:48 | 7/1/21 13:00 | Elisa | Home | Starting |
| 9 | 8/1/21 8:03 | 8/1/21 13:20 | John | Office | Finishing |
| 10 | 8/1/21 8:46 | 8/1/21 13:03 | Elisa | Home | Finishing |
Hello fabinishi1207
Try this measure below
TimeWork =VAR DATEDIFF = DATEDIFF(MINX(Table,Table[Start time]),MAXX(Table,Table[End Time]),MINUTE)returnDATEDIFFBest Regards
2 Replies
- PortrekResolver III
Hello fabinishi1207
Try this measure below
TimeWork =VAR DATEDIFF = DATEDIFF(MINX(Table,Table[Start time]),MAXX(Table,Table[End Time]),MINUTE)returnDATEDIFFBest Regards- AnonymousNot applicable
Hi Portrek,
Thanks for the feedback but unfortunately it didn't work as expected.