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

Variable in Load Statement

Hello smart people,

        I'm trying to use a variable in a load statement that pulls data from a QVD. Unfortunalety it is not going as I'd hoped. Perhaps someone can help?

Let vMinDate = '3/1/2014';

MY_TABLE:

LOAD MY_ID,
          CLOSE_DATE,
          IF(CLOSE_DATE>=$(vMinDate),1,0)  AS  TBLBOX_FILTER

FROM
[$(vQVDFilePath)\MY_TABLE.QVD](
qvd);


When I run this, all values in TBLBOX_FILTER end up as 1, regardless of CLOSE_DATE. There should be some records with 0, as there is data with a CLOSE_DATE prior to 3/1/2014.

If I change the IF statement to have a hard-coded date:

IF(CLOSE_DATE>='3/1/2014',1,0)  AS  TBLBOX_FILTER

It works the way I want it - some records have 0 and some have 1.

Any idea as to why it using the variable doesn't function properly?

Thanks,

Brent


1 Solution

Accepted Solutions
ramoncova06
Specialist III
Specialist III

try adding quotes to you variables IF(CLOSE_DATE>='$(vMinDate)',1,0) 

View solution in original post

2 Replies
ramoncova06
Specialist III
Specialist III

try adding quotes to you variables IF(CLOSE_DATE>='$(vMinDate)',1,0) 

Not applicable
Author

That did it. It seems a little strange. You would think that if it were surrounded by single quotes it would think the text between was literal and not a variable.

Thank you for you help and quick response!