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

Not able to check the condition

Hi Friends,

I have declared a variable like this 

LET vAccountingPeriod=Date#(ADDMONTHS(YEARSTART(Now()),-12),'YYYYMM');

Which is equal to 201401.

and loaded the data like

Load * from table

where Date#([Acct-PrdOO],'YYYYMM')>Date#($(vAccountingPeriod),'YYYYMM');

But I am getting all the data and  the check condition is failing.

Please let me know the error in the code.....

Thanks

1 Solution

Accepted Solutions
Gysbert_Wassenaar

Try:


LET vAccountingPeriod= floor(ADDMONTHS(YEARSTART(Now()),-12));


Load * from table

where floor(Date#([Acct-PrdOO],'YYYYMM')) > $(vAccountingPeriod);


talk is cheap, supply exceeds demand

View solution in original post

4 Replies
Not applicable
Author

As you have already set the format in the variable, you should be able to just use


where Date#([Acct-PrdOO],'YYYYMM')>'$(vAccountingPeriod)';

hope that helps

Joe

Gysbert_Wassenaar

Try:


LET vAccountingPeriod= floor(ADDMONTHS(YEARSTART(Now()),-12));


Load * from table

where floor(Date#([Acct-PrdOO],'YYYYMM')) > $(vAccountingPeriod);


talk is cheap, supply exceeds demand
Not applicable
Author

Hi Gysbert

Its working!!! Could I know the reason please

Gysbert_Wassenaar

When using dates in comparisons it's often wise to use only the numeric value and not mess around with the different format string representations of the dates.


talk is cheap, supply exceeds demand