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

Announcements
Qlik Connect 2026! Turn data into bold moves, April 13 -15: Learn More!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Save Last and before last dates in Date field as Script variables and using them with in the script in where condition..

Can I save Last and before last dates in a date field as script variables and use them in where condition while joinning?

1 Solution

Accepted Solutions
Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

Sure, assuming your date field is named Date:

LET vLastDate = peek('Date');

LET vBeforeLastDate = peek('Date',-2);

If you want the max and second highest try:

Temp:

load max(Date) as Max1, max(Date,2) as Max2

Resident ...table_with_dates...;

LET vMax1 = peek('Max1');

LET vMax2 = peek('Max2');

drop Table Temp;

You can use the variables like this:

load * from ...sometable...

where OrderDate <= $(vLastDate) ;


talk is cheap, supply exceeds demand

View solution in original post

2 Replies
Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

Sure, assuming your date field is named Date:

LET vLastDate = peek('Date');

LET vBeforeLastDate = peek('Date',-2);

If you want the max and second highest try:

Temp:

load max(Date) as Max1, max(Date,2) as Max2

Resident ...table_with_dates...;

LET vMax1 = peek('Max1');

LET vMax2 = peek('Max2');

drop Table Temp;

You can use the variables like this:

load * from ...sometable...

where OrderDate <= $(vLastDate) ;


talk is cheap, supply exceeds demand
Not applicable
Author

Thanks..