Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi
Please see sample data attached.
What I'm trying to do is find the duration between start and finish times for each employee for each date.
Im thinking something along the lines of :
If event type = F THEN use the previous row to get TimeIn and then work out the difference between the two time.
Bear in mind dates would have to be sorted correctly so it starts at the right point and the system would need to account for when it moves onto a row with a new employee.
Please could you assist.
Many thanks
Hi,
maybe one solution could be:
table1:
LOAD *,
Timestamp(Floor(Date)+Alt(TimeIn,TimeOut)) as DateTime,
If(IsNum(TimeIn),'In','Out') as InOut
FROM [https://community.qlik.com/servlet/JiveServlet/download/1494633-327233/Sample%20Data1.xlsx] (ooxml, embedded labels, table is time);
table2:
LOAD Code,
FullName,
Previous(DateTime) as DateTimeIn,
DateTime as DateTimeOut,
Interval(DateTime-Previous(DateTime)) as Duration
Resident table1
Where InOut='Out' and Previous(InOut)='In' and Code=Previous(Code)
Order By Code, DateTime;
DROP Table table1;
hope this helps
regards
Marco
See attached qvw:
Hi,
maybe one solution could be:
table1:
LOAD *,
Timestamp(Floor(Date)+Alt(TimeIn,TimeOut)) as DateTime,
If(IsNum(TimeIn),'In','Out') as InOut
FROM [https://community.qlik.com/servlet/JiveServlet/download/1494633-327233/Sample%20Data1.xlsx] (ooxml, embedded labels, table is time);
table2:
LOAD Code,
FullName,
Previous(DateTime) as DateTimeIn,
DateTime as DateTimeOut,
Interval(DateTime-Previous(DateTime)) as Duration
Resident table1
Where InOut='Out' and Previous(InOut)='In' and Code=Previous(Code)
Order By Code, DateTime;
DROP Table table1;
hope this helps
regards
Marco
Thank you Marco - this works perfect.
Thank you mw - this also works perfect.