Skip to main content
Announcements
Live today at 11 AM ET. Get your questions about Qlik Connect answered, or just listen in. SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

findout date exists in an interval

I have date information in two separate tables and i want to find if a date from table1.date exists in between date ranges of table 2 (date1.table2 and date2.table2). on the basis of the comparison i want to add a comment.

TABLE1:

EmployeeIDabsencedate
000101.01.2013
000202.02.2012
000303.03.2012

TABLE2:

EmployeeIDLeaveFrom
LeaveTo
000112.12.201225.12.2012
000201.02.201205.02.2012
000303.03.201203.03.2012

RESULT TABLE should be like this:

EMPLOYEEIDABSENCEDATEComments
00101.01.2013not found
000202.02.2012found
000303.03.2012found

it would be great if i can achieve it through scripting.

15 Replies
Not applicable
Author

LeaveTo is not null

EmployeeIDLeaveFromLeaveTo
367305-01-201206-01-2012
367313-01-201213-01-2012
367329-03-201229-03-2012
367304-06-201215-06-2012
367313-07-201213-07-2012
367326-07-201226-07-2012
Not applicable
Author

Hi, We used a join function know that a Y we face like this,,

We have to find  alternative way to finish this..

Not applicable
Author

Thanks Kabilan

The alternative i think could be IntervalMatch,,, but again its not working for me.. Can u see please this code.. y this is not working??

TABLE2:
LOAD * INLINE [
EmployeeID, LeaveFrom, LeaveTo
0001, 12.12.2012, 25.12.2012
0002, 01.02.2012, 05.02.2012
0003, 03.03.2012, 03.03.2012
];

TABLE1:
LOAD * INLINE [
EmployeeID, absencedate
0001, 01.01.2013
0002, 02.02.2012
0003, 03.03.2012
];

LEFT JOIN
IntervalMatch(absencedate)
LOAD
LeaveFrom,
LeaveTo
RESIDENT TABLE2;

DROP Table TABLE2;

TABLE3:
LOAD *,
     If(IsNull(LeaveFrom)=-1, 'not found', 'found') as Comment
RESIDENT TABLE1;

DROP TABLE TABLE1;

Not applicable
Author

hello Sidrahasan,

Try this code.

 


test:

LOAD EmployeeID,
     num(date(date#(absencedate,'DD.MM.YYYY'),'MMDDYYYY')) as absencedate
FROM
[http://community.qlik.com/message/296652#296652]
(html, codepage is 1252, embedded labels, table is @1);

left join

LOAD EmployeeID,
     num(date(date#(LeaveFrom,'DD.MM.YYYY'),'MMDDYYYY')) as leavefrom ,
     num(date(date#(LeaveTo,'DD.MM.YYYY'),'MMDDYYYY')) as leaveto
    
FROM
[http://community.qlik.com/message/296652#296652]
(html, codepage is 1252, embedded labels, table is @2);


test1:
load EmployeeID,
  absencedate,
  leavefrom,
  leaveto,
  if(absencedate >= leavefrom and absencedate <= leaveto,'found','notfound') as comment
  Resident test;
 
  drop table test;

Pls reply.

 

Not applicable
Author

Thanks nazneen for the reply.

Your code is same as Kbilan mentioned above and its not working as its joining one absence date to all leaveTOo and LeaveFrom date hence producing both the Result for a record.

Not applicable
Author

Hi,

U can create a calulated dimension like below

=if(IsNull(Start) and IsNull(End),'Not Found','Found')

PFA,

Regards,

Kabilan K