Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Where is the error?

Hi!! I can't find where is the error in this scrip: (in DATABASE1 there is DATAWORK '01/01/2009 00:00')

Let vCurrentYear=year(today());

SQL SELECT *,

FROM $(db).dbo.DATABASE1;

Load

date(DATAWORK),

if(Year(date(DATAWORK))=Year($(vCurrentYear))-1, NUM_SALE) as NUM_SALE_2008

Resident DATABASE1;



HELP ME pls!!!!!

Thankyou very much

1 Reply
Anonymous
Not applicable
Author

Can't tell about some specifics - not enough info. But there are at least 2 issues:
1. Comma after *.
2. Variable vCurrentYear is 2009. The function Year(2009) returns 1905, because the date(2009) is July 1, 1905. If you want previous year, it should be just $(vCurrentYear)-1.
(And, the field name probably should bebetter NUM_SALES_LASTYEAR instead of NUM_SALES_2008.)