Qlik Community

QlikView App Development

Discussion Board for collaboration related to QlikView App Development.

mayankraoka
Valued Contributor

Rolling current 4 weeks and past 4 weeks flag in scripting

Hi All,

I have data for 13 weeks having week id from 1 to 13.

I want to calculate rolling 4 weeks volume and growth.For this I know to calculate the rolling 4 weeks(Which include week 13,12,11,10) on expression level.

The solution ,I am looking to calculate flags for Current rolling 4 weeks((wk id=13,12,11,10)) and past rolling 4 weeks(wk id=9,8,7,6)

in the script .Instead of calculating them om expression.

Can anyone tell me how to do this in script?

Regards,

Mayank

1 Solution

Accepted Solutions
MVP
MVP

Re: Rolling current 4 weeks and past 4 weeks flag in scripting

if you already have the week id

match(weekid, 13, 12, 11, 10) as flagcurrent

match(weekid, 9, 8, 7, 6)  as flagpast




3 Replies
MVP
MVP

Re: Rolling current 4 weeks and past 4 weeks flag in scripting

if you already have the week id

match(weekid, 13, 12, 11, 10) as flagcurrent

match(weekid, 9, 8, 7, 6)  as flagpast




mayankraoka
Valued Contributor

Re: Rolling current 4 weeks and past 4 weeks flag in scripting

Hi Maxgro,

Thank you for reply..

When I am writing below code in script :

Time:

LOAD WEEK_ID,

if(WEEK_ID= match(WEEK_ID, 5, 6, 7, 😎 ,1,0) as flagpast,

    if(WEEK_ID= match(WEEK_ID, 1, 2, 3, 4),1,0) as flagcurrent,

     WEEK_DT,

Getting below values for both the fields:

Why only 0 value for flag past?:Why this behaviour?

Image1.JPG

Regards,

Mayank

MVP
MVP

Re: Rolling current 4 weeks and past 4 weeks flag in scripting

1.png

Week:

load rowno() as WEEK_ID

AutoGenerate 13;

Time:

LOAD

  WEEK_ID,

  if(match(WEEK_ID, 9, 8, 7, 6),1,0) as flagpast,

    if(match(WEEK_ID, 13, 12, 11, 10),1,0) as flagcurrent

Resident Week;