Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements
QlikView Fans! We’d love to hear from you.
Share your QlikView feedback with the product team… Click here to participate in our 5-minute survey.
Rules, plus terms and conditions, can be found here.
Not applicable

To create month period that start from Feb 20-Mar 19 = Month 1

Hi,

I have to create month period field that starts from

Feb 20, 2009-Mar 19, 2009 = Month 1

Mar 20, 2009-Apr 19, 2009 = Month 2

Apr 20, 2009-May 19, 2009 = Month 3

May 20, 2009-Jun 19, 2009 = Month 4

Jun 20, 2009-Jul 19, 2009 = Month 5

Jul 20, 2009-Aug 19, 2009 = Month 6

Aug 20, 2009-Sep 19, 2009 = Month 7

Sep 20, 2009-Oct19, 2009 = Month 8

Oct 20, 2009-Nov 19, 2009 = Month 9

Nov 20, 2009-Dec 19, 2009 = Month 10

Dec 20, 2009-Jan 19, 2010 = Month 11

Jan 20, 2010-Feb19, 2010= Month 12

What should I do for this case? I have tried to do if-else but it doesnt work. Also, attached my dateIsland.qvw to create master calendar. Please help me

Tags (1)
1 Solution

Accepted Solutions
mov
Esteemed Contributor III

Re: To create month period that start from Feb 20-Mar 19 = Month 1

Tawin,

If you have fields DateId and Day in your calendar (table Date), add this script:

LEFT JOIN (Date) LOAD

DateId,

'Month ' &

  if(Day<=19,

  num(month(addmonths(DateId,-2))),

  num(month(addmonths(DateId,-1)))) as ModifiedMonth

RESIDENT Date;

And, see attached.

Regards,

Michael

3 Replies
edg_baltazar
Contributor

Re: To create month period that start from Feb 20-Mar 19 = Month 1

A fast way to do this is to create a table in excel containing the next fields... master_date and alternative_month, fill master_date field with all dates of the year and fill alternative_month with the corresponding new value of month then load this excel into qlikvew and make a left join to the master calendar with this new table , now your master_calendar will have a new field called alternative_month where you are going to have this new month that you want, regards!

mov
Esteemed Contributor III

Re: To create month period that start from Feb 20-Mar 19 = Month 1

Tawin,

If you have fields DateId and Day in your calendar (table Date), add this script:

LEFT JOIN (Date) LOAD

DateId,

'Month ' &

  if(Day<=19,

  num(month(addmonths(DateId,-2))),

  num(month(addmonths(DateId,-1)))) as ModifiedMonth

RESIDENT Date;

And, see attached.

Regards,

Michael

Not applicable

Re: To create month period that start from Feb 20-Mar 19 = Month 1

It rocks, thank you very much

Community Browser