Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements
Leverage your QlikView investment to modernize BI – see how! Join Group
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Creator II
Creator II

Re: How to create a rolling 12 months flag in the script?

Hi Sunny,

This doesn't quite work because it does Feb 2017 and includes Jan 2018.

I want it to be ALL of January, up to the end of Dec 2017.

So it should not include the current month.

Highlighted

Re: How to create a rolling 12 months flag in the script?

How about this

If(DateField >= MonthStart(Today(), -12) and DateField < MonthStart(Today()), 1, 0) as R12M_Flag

Highlighted
Creator II
Creator II

Re: How to create a rolling 12 months flag in the script?

Hi Sunny,

Will this include data from the start of the month 12 months ago? i.e. From January 1st? Or Feb 1st? Mar 1st? etc naturally?

This almost work I just want to check the above!

Highlighted

Re: How to create a rolling 12 months flag in the script?

MonthStart should take your to the beginning of the day... so since today is Jan 15th... we should see this from the above

>= 01/01/2017<01/01/2018

here 01/01/2018 won't be included as we have used less than (and not less than equal to)

Highlighted
Creator II
Creator II

Re: How to create a rolling 12 months flag in the script?

So if I use <= it will include data from the first day of each month?

Highlighted

Re: How to create a rolling 12 months flag in the script?

No that is not what I meant.... what I trying to say is that since today is Jan 2018... you hopefully want to just include until the last day of Dec 2017, right? If that is true, then the above script should work for you

Highlighted
Contributor III
Contributor III

Re: How to create a rolling 12 months flag in the script?

Michael,

    You still haven't solved this you try the following.

,InMonths(12, D, Today(), -1, num(month(Today()))) as Previous12Months