Skip to main content
Announcements
Live today at 11 AM ET. Get your questions about Qlik Connect answered, or just listen in. SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

I need the last 12/13 months data only

Hi Guy's,

I need your expert help yet again, the dates are coming out in from the SQL warehouse as "201509" which equals Sept 2015, what function and code do i use if i want the last 13 months of data.

Thanks

1 Solution

Accepted Solutions
simondachstr
Luminary Alumni
Luminary Alumni

Try using the following

let vWhere = Date(addmonths(today(),-13),'YYYYMM');

View solution in original post

4 Replies
marcus_sommer

You need to create a variable for your where-clause - try something like this:

let vWhere = if(num(month(today()))=1,

     (year(today()) - 2) * 100 + 12, year(today()) - 2) * 100 + num(month(today())) - 1);

table:

SQL Select * From YourDB where Date >= $(vWhere);

- Marcus

Anonymous
Not applicable
Author

I'm getting a error in the

let vWhere = if(num(month(today()))=1,

     (year(today()) - 2) * 100 + 12, year(today()) - 2) * 100 + num(month(today())) - 1);


code in QS

simondachstr
Luminary Alumni
Luminary Alumni

Try using the following

let vWhere = Date(addmonths(today(),-13),'YYYYMM');

Anonymous
Not applicable
Author

I think that's worked, fingers crossed.  Thanks guys