Qlik Community

Qlik Sense App Development

Discussion board where members can learn more about Qlik Sense App Development and Usage.

farisahamad
Contributor

Load dates in script

I want to create a list in the script which contains all the last 11 months, which will get updated dynamically

For example if i am running the app on 27th Sept 2017 , i should get the following list :


Oct 2016

Nov 2016

Dec 2016

Jan 2017

Feb 2017

Mar 2017

Apr 2017

May 2017

Jun 2017

Jul 2017

Aug 2017

Please help me on this.

1 Solution

Accepted Solutions
MVP
MVP

Re: Load dates in script

Table:

load

Date(AddMonths(MonthStart(today()), -iterno()), 'MMM YY') as Date

AutoGenerate 1

While IterNo() <= 11;

1.png

7 Replies
YoussefBelloum
Esteemed Contributor

Re: Load dates in script

Hi,

here is one of the methods to do it:

SET v_STARTDATE = '01/01/2016';

SET v_ENDDATE = '01/12/2017';

TMP_DATE:

LOAD date(date#('$(v_STARTDATE)','DD/MM/YYYY')-1 + recno() ,'DD/MM/YYYY') as Date

AUTOGENERATE (date#('$(v_ENDDATE)','DD/MM/YYYY') - date#('$(v_STARTDATE)','DD/MM/YYYY')) + 1 ;

DATE_TABLE:

LOAD

*,

Month(Date)&Year(Date) as Month_year

RESIDENT TMP_DATE

where Date < AddMonths(today(),-1) and Date > AddMonths(today(),-11);

DROP TABLE TMP_DATE;


Hope it helps

YB

farisahamad
Contributor

Re: Load dates in script

Hi,

Thanks for the reply . But i dont want to hardcode the end date.can we make it as today()?

MVP
MVP

Re: Load dates in script

Table:

load

Date(AddMonths(MonthStart(today()), -iterno()), 'MMM YY') as Date

AutoGenerate 1

While IterNo() <= 11;

1.png

YoussefBelloum
Esteemed Contributor

Re: Load dates in script

Yes for sure you can put whatever you want in the variables.

Tell me if you want an example

farisahamad
Contributor

Re: Load dates in script

Thank you.This is exactly whai wanted

farisahamad
Contributor

Re: Load dates in script

Thank you Youssef for ur support

YoussefBelloum
Esteemed Contributor

Re: Load dates in script

you're welcome !