Discussion board where members can get started with QlikView.
I want to load sales data only for the latest 24 months. I tried to realize it with the script below, but QV always comes up with an error message:
from table1 where ([SalesDate]>Date(addmonths(max(SalesDate), -23), 'DD.MM.YYYY'));
Any suggestions? I'd appreciate it.
Go to Solution.
try with a variable, bold in the script below
// test data
iterno() as Product,
Date( makedate(2014) + floor(rand()*365*4)) as SalesDate,
rand()*100 as Sales
While IterNo() <= 10000;
// calc the date from and set the variable
load max(SalesDate) as MaxSalesDate Resident T;
LET vMaxSalesDate = Date( AddMonths(Peek('MaxSalesDate', 0, T), -24));
DROP Table M;
// filter with the variable
NoConcatenate LOAD *
where SalesDate > '$(vMaxSalesDate)';
DROP Table T;
View solution in original post
Alternatively, If you have full dates you can work like
from table1 where SalesDate>Date(addyears(Today(), -2), 'DD.MM.YYYY') and SalesDate<=Date(Today(), 'DD.MM.YYYY');
it works! Great! Many thanks!
unfortunately, using today() is not an option. But thanks for the help.