Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
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

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

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..