Qlik Community

Ask a Question

QlikView App Dev

Discussion Board for collaboration related to QlikView App Development.

Announcements
Become an analytics expert with Qlik's new 15 week course: Applied Data Analytics using Qlik Sense. READ MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
roy_fredericks
Contributor
Contributor

Duration between times over two rows

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

1 Solution

Accepted Solutions
MarcoWedel

Hi,

maybe one solution could be:

QlikCommunity_Thread_303257_Pic1.JPG

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

View solution in original post

4 Replies
m_woolf
Master II
Master II

See attached qvw:

MarcoWedel

Hi,

maybe one solution could be:

QlikCommunity_Thread_303257_Pic1.JPG

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

View solution in original post

roy_fredericks
Contributor
Contributor
Author

Thank you Marco - this works perfect.

roy_fredericks
Contributor
Contributor
Author

Thank you mw  - this also works perfect.