Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Autogenerate months based on start and end date

Hello,

I have products and start and end dates of their marketing campaigns. I am having trouble figuring out how to autogenerate month names that fall within each campaign's start and end date in the script.

Attached is the working file and the text object next to the table that shows desired result.

Thanks,

M

1 Solution

Accepted Solutions
Gysbert_Wassenaar

Try :

table:

LOAD * Inline [

Product,    Campaign,        StartDate,        EndDate

A,            1,                1/1/2011,        3/1/2011

A,            2,                3/2/2011,        7/1/2011

A,            3,                7/2/2011,        12/1/2011

B,            1,                1/1/2012,        3/1/2012

B,            2,                3/2/2012,        7/1/2012

B,            3,                7/2/2012,        12/1/2012

];

T2:

load *, date(AddMonths(StartDate,IterNo()-1),'MMM-YY') as MonthName

Resident table While AddMonths(StartDate,IterNo()-1)<EndDate;

drop table table;

T3:

load Product,Campaign,StartDate,EndDate, Concat(MonthName,', ',num(MonthName) ) as Months

Resident T2 group by Product,Campaign,StartDate,EndDate;

drop table T2;


talk is cheap, supply exceeds demand

View solution in original post

2 Replies
Gysbert_Wassenaar

Try :

table:

LOAD * Inline [

Product,    Campaign,        StartDate,        EndDate

A,            1,                1/1/2011,        3/1/2011

A,            2,                3/2/2011,        7/1/2011

A,            3,                7/2/2011,        12/1/2011

B,            1,                1/1/2012,        3/1/2012

B,            2,                3/2/2012,        7/1/2012

B,            3,                7/2/2012,        12/1/2012

];

T2:

load *, date(AddMonths(StartDate,IterNo()-1),'MMM-YY') as MonthName

Resident table While AddMonths(StartDate,IterNo()-1)<EndDate;

drop table table;

T3:

load Product,Campaign,StartDate,EndDate, Concat(MonthName,', ',num(MonthName) ) as Months

Resident T2 group by Product,Campaign,StartDate,EndDate;

drop table T2;


talk is cheap, supply exceeds demand
Not applicable
Author

Thank you! That did it for me!