Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements

Breathe easy -- you now have more time to plan your next steps with Qlik!
QlikView 11.2 Extended Support is now valid through December 31, 2020. Click here for more information.

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

Tags (1)
1 Solution

Accepted Solutions
Gysbert_Wassenaar
Not applicable

Re: Not able to check the condition

Try:


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


Load * from table

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


talk is cheap, supply exceeds demand
4 Replies
Not applicable

Re: Not able to check the condition

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
Not applicable

Re: Not able to check the condition

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

Re: Not able to check the condition

Hi Gysbert

Its working!!! Could I know the reason please

Gysbert_Wassenaar
Not applicable

Re: Not able to check the condition

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