Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
rupaliqlik
Creator
Creator

Peek max record on selection of date range

Hi all,

I have a JOB_RPT table where I applied logic for latest record,now challenge is that I received one sql query where user filter record in front end by selecting date range.So  that my record should reduced according to date range.But logic failed to achieve.Below max record is 3/1/2001 but if he select date <=1/1/2000 then latest record should be 1/1/2000.Please help me.

(SELECT MAX(A_ED.EFFDT) FROM sysadm.PS_JOB_RPT A_ED
WHERE A.EMPLID = A_ED.EMPLID
AND A.EMPL_RCD = A_ED.EMPL_RCD
AND A_ED.EFFDT <= TO_DATE(:1,'YYYY-MM-DD'))     ------ it is variable in peoplesoft tool wherre user pass value

 

6618/1/1994District Manager
6618/1/1995District Manager
6611/1/1996Mgr
6611/3/1997Mgr
6618/11/1997Dir
6611/1/1998Dir
6618/1/1998Dir
6613/1/1999Dir
6615/1/1999Dir
66111/17/1999Dir
6611/1/2000VP
6612/1/2001VP
6613/1/2001VP

 

  kaushik.solanki 

Labels (1)
1 Reply
Lauri
Specialist
Specialist

I think Peek is the right function to use. Try this:

tblUserDate:
Load date(MDate) as UserMaxDate;
SQL SELECT MAX(A_ED.EFFDT) as MDate FROM sysadm.PS_JOB_RPT A_ED
WHERE A.EMPLID = A_ED.EMPLID
AND A.EMPL_RCD = A_ED.EMPL_RCD
AND A_ED.EFFDT <= TO_DATE(:1,'YYYY-MM-DD');

Let vUserDate = Peek('UserMaxDate', 0, 'tblUserDate');

You can drop tblUserDate.

Now use vUserDate to filter your table.