Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
where condition is not working in script.. below i am using.
where Date#(Calendar_Month,'YYYYMM')<=date(addmonths(today()-2,-45),'YYYYMM')
---Calendar_month -- No months its showing as DB there is values for this CalendarMonth.
when i hardcode the field its working. like below
where Calendar_month<='201709'; ----- this is working.
what might be the issue with first where condition?
how can i modify the where condition expression?
thanks
Try like:
Date#(Calendar_Month,'YYYYMM')<=addmonths(today()-2,-45)
And also note,
Date(addmonths(today()-2,-45),'YYYYMM') = '201508' // Is this the value you want to compare with?
I think your issue is that you want to compare "normal" numbers against dates (it are also numbers but a bit different - and independent from their formatting) and in this way they don't match.
To get your showed numbers you could use the following logic:
year(date) * 100 + month(date)
Quite similar and in your case probaly more suitable would be to use a consecutive YearMonth counter which could be created with:
year(date) * 12 + month(date)
and then you could use a where-clause like:
where year(date) * 12 + month(date) <= (year(today()-2) * 12 + month(today()-2)) - 45
Even more useful would be to add the above created YearMonth period-fields as standard fields within all your qvd's. It simplifies such where-clauses and provides also the possibility to pre-load the required time-frame within an autogenerate load like:
PeriodDummy: load (year(today()-2) * 12 + month(today()-2)) + 1 - recno() as Period autogenerate 45;
and the using a where exists() to keep the qvd-loading optimized like:
where exists(Period);
- Marcus
When you say the condition is not working in the script? Do you mean it brings back no result? Or does it bring different number of records? This might make help if the number of records are different
Where Date#(Calendar_Month, 'YYYYMM') <= MonthStart(Today()-2, -45);
Because when you entered 201709... it automatically assumed beginning of the month, but when you use AddMonths, it take you back 45 months to the exact date instead of beginning of the month. You can use MonthStart instead of AddMonths
Try like:
Date#(Calendar_Month,'YYYYMM')<=addmonths(today()-2,-45)
And also note,
Date(addmonths(today()-2,-45),'YYYYMM') = '201508' // Is this the value you want to compare with?
Hi Tresesco yeah application is running in Qmc... once done i will update you.
and calendar month format is YYYYMM only.
You mention a DB in your description. If you tries to apply Qlik functions within the sql-query it will fail. In this case you need to apply functions which your database and the used driver supports or if the queried dataset isn't too large you could apply the condition within a preceeding load, like:
load * where Condition;
sql select * from DB;
- Marcus