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

Announcements
Discover how organizations are unlocking new revenue streams: Watch here
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Script help

Hello All,

I am working on Attendance Tracking system.

And want to find such employees who are Absent for 7 or more consecutive days.(Working days)

I have the following fields in it.

Empid,Date,Status

Status has the values as Present,Absent.Off

How do I proceed to get a solution.

Thanks and Regards,

Priya

1 Solution

Accepted Solutions
jonathandienst
Partner - Champion III
Partner - Champion III

Hi

You need something like this:

Load your existing data:

Data1:

LOAD EmpID,

  Date,

  Status,

  ...

FROM .....;

Now load from the Data resident

Data2:

LOAD *,

  If(EmpID = Previous(EmpID),

  If(Previous(Status) = 'Absent' And Status = 'Absent',

  Peek('ConsecutiveAbsentDays') + 1,

  If(Status = 'Absent', 1, 0)

  ),

  If(Status = 'Absent', 1, 0)

  ) As ConsecutiveAbsentDays

Resident Data1

ORDER BY EmpID, Date;

Finally drop the first Data table:

DROP Table Data1;

Now you can create an straight table object with Dimension EmpID and expression If(Max(ConsecutiveAbsentDays) >= 7, 'Absent > 7 Days') and ensure that suppress 0 and suppress missing options are on

HTH

Jonathan

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein

View solution in original post

5 Replies
jsingh71
Partner - Specialist
Partner - Specialist

Can you upload some sample data.

MK_QSL
MVP
MVP

Can you load your sample data file?

Not applicable
Author

Hello All,

Pls Find the sample data.

Thanks & Regards,

Priya

jonathandienst
Partner - Champion III
Partner - Champion III

Hi

You need something like this:

Load your existing data:

Data1:

LOAD EmpID,

  Date,

  Status,

  ...

FROM .....;

Now load from the Data resident

Data2:

LOAD *,

  If(EmpID = Previous(EmpID),

  If(Previous(Status) = 'Absent' And Status = 'Absent',

  Peek('ConsecutiveAbsentDays') + 1,

  If(Status = 'Absent', 1, 0)

  ),

  If(Status = 'Absent', 1, 0)

  ) As ConsecutiveAbsentDays

Resident Data1

ORDER BY EmpID, Date;

Finally drop the first Data table:

DROP Table Data1;

Now you can create an straight table object with Dimension EmpID and expression If(Max(ConsecutiveAbsentDays) >= 7, 'Absent > 7 Days') and ensure that suppress 0 and suppress missing options are on

HTH

Jonathan

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
Not applicable
Author

Try the attached.