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

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Auto Generate Calendar

Hi All,

I need some help from community. Assume I have the following SourceDate with MMM-YY format:

 

SourceDate
Oct-15
Sep-15
Aug-15
Jul-15
Jun-15
May-15
Apr-15
Mar-15
Feb-15
Jan-15
Dec-14

And now I need to auto generate a ReportDate field in order to get previous month year until the current month year in the table. The following table is the result which is I want.

  

SourceDateReportDate
Oct-15Oct-15
Oct-15Sep-15
Oct-15Aug-15
Oct-15Jul-15
Oct-15Jun-15
Oct-15May-15
Oct-15Apr-15
Oct-15Mar-15
Oct-15Feb-15
Oct-15Jan-15
Sep-15Sep-15
Sep-15Aug-15
Sep-15Jul-15
Sep-15Jun-15
Sep-15May-15
Sep-15Apr-15
Sep-15Mar-15
Sep-15Feb-15
Sep-15Jan-15
Aug-15Aug-15
Aug-15Jul-15
Aug-15Jun-15
Aug-15May-15
Aug-15Apr-15
Aug-15Mar-15
Aug-15Feb-15
Aug-15Jan-15
Jul-15Jul-15
Jul-15Jun-15
Jul-15May-15
Jul-15Apr-15
Jul-15Mar-15
Jul-15Feb-15
Jul-15Jan-15
Jun-15Jun-15
Jun-15May-15
Jun-15Apr-15
Jun-15Mar-15
Jun-15Feb-15
Jun-15Jan-15
May-15May-15
May-15Apr-15
May-15Mar-15
May-15Feb-15
May-15Jan-15
Apr-15Apr-15
Apr-15Mar-15
Apr-15Feb-15
Apr-15Jan-15
Mar-15Mar-15
Mar-15Feb-15
Mar-15Jan-15
Feb-15Feb-15
Feb-15Jan-15
Jan-15Jan-15
Dec-14Dec-14
Dec-14Nov-14
Dec-14Oct-14
Dec-14Sep-14
Dec-14Aug-14
Dec-14Jul-14
Dec-14Jun-14
Dec-14May-14
Dec-14Apr-14
Dec-14Mar-14
Dec-14Feb-14
Dec-14Jan-14

Anyone know anyway to doing it? I am very appreciate for your help.

Thanks.

Best Regards.

Labels (1)
1 Solution

Accepted Solutions
Digvijay_Singh
MVP
MVP

Try this -

T1:

Load Date(Date#(SourceDate,'MMM-YY'),'MMM-YY') as SourceDate,

  Month(SourceDate) as Month

inline [

SourceDate

Oct-15

Sep-15

Aug-15

Jul-15

Jun-15

May-15

Apr-15

Mar-15

Feb-15

Jan-15

Dec-14 ];

Final:

Load Date(Date#(SourceDate,'MMM-YY'),'MMM-YY') as SourceDate,

  Date(AddMonths(SourceDate,-Iterno()),'MMM-YY') as ReportDate

Resident T1 

While Iterno()<=Month(SourceDate)-1;

DROP Table T1;

View solution in original post

2 Replies
Digvijay_Singh
MVP
MVP

Try this -

T1:

Load Date(Date#(SourceDate,'MMM-YY'),'MMM-YY') as SourceDate,

  Month(SourceDate) as Month

inline [

SourceDate

Oct-15

Sep-15

Aug-15

Jul-15

Jun-15

May-15

Apr-15

Mar-15

Feb-15

Jan-15

Dec-14 ];

Final:

Load Date(Date#(SourceDate,'MMM-YY'),'MMM-YY') as SourceDate,

  Date(AddMonths(SourceDate,-Iterno()),'MMM-YY') as ReportDate

Resident T1 

While Iterno()<=Month(SourceDate)-1;

DROP Table T1;

marcus_sommer
MVP
MVP

For generating calendars have a look here: How to use - Master-Calendar and Date-Values and I think this will be helpful, too: The As-Of Table.

- Marcus