Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Time Difference from min row to max row in groups

Sorry if the title didn't explain it well.

I am trying to pull the amount of time each employee worked in each period.  Then total them for each WorkCode. 

Example: The employee worked 49:41 before they clocked a 15 Break. 

EmpIDWorkCodeWorkDescDateTm
232Work3/12/2013 8:06:02
232Work3/12/2013 8:42:12
23515 Break3/12/2013 8:55:43
232Work3/12/2013 9:09:52
232Work3/12/2013 10:37:27
232Work3/12/2013 11:24:01
237Lunch3/12/2013 12:03:42
232Work3/12/2013 13:01:47
232Work3/12/2013 14:32:31
23515 Break3/12/2013 15:03:45
232Work3/12/2013 15:18:50

I tried using Autonumber but it generated teh _AutoNumberSerial below.

Work:

Load *,

          AutoNumber(EmpID & WorkCode, '_WorkSerial') as _WorkCodeSerial

Resident tWork

Order by EmpID , DateTm;

EmpIDWorkCodeWorkDescDateTm_AutoNumberSerial_DesiredSerial
232Work3/12/2013 8:0611
232Work3/12/2013 8:4211
23515 Break3/12/2013 8:5522
232Work3/12/2013 9:0913
232Work3/12/2013 10:3713
232Work3/12/2013 11:2413
237Lunch3/12/2013 12:0334
232Work3/12/2013 13:0115
232Work3/12/2013 14:3215
23515 Break3/12/2013 15:0326
232Work3/12/2013 15:1817

I was trying to get the _DesiredSerial.  I figure I could combine the WorkCode & _DesiredSerial and then get the min and max times grouped by the new combined value.

I would greatly appreciate the help.  If you know of a better way to pull these values than what I have proposed that would be great as well.

Thanks

0 Replies