Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

lakwinder
Contributor III

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
Luminary
Luminary

Re: I need the last 12/13 months data only

Try using the following

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

4 Replies

Re: I need the last 12/13 months data only

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

lakwinder
Contributor III

Re: I need the last 12/13 months data only

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

Luminary
Luminary

Re: I need the last 12/13 months data only

Try using the following

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

lakwinder
Contributor III

Re: I need the last 12/13 months data only

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

Community Browser