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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

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:

fabnishi1207_1-1625237219862.png

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

 

 

 

 

 

1 ACCEPTED SOLUTION
Portrek
Resolver III
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

View solution in original post

2 REPLIES 2
Portrek
Resolver III
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
Not applicable

Hi Portrek,

 

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

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.