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

For loop increment by every month

hello guys ,

I need Value 12 for 1st four months and then another set of value  from 2nd months onwards and so on as shown below .

I need to autogenerate value 12 four times every coming month and so on till 20 months .

Months12345678910
112
21212
3121212
412121212
5 121212
6 1212
7 12
8 12
9 12
10 12
12

Here is my script it does not give me desired results . Could u plz help me with solution .  When i use Value and Month in the chart i will get value= 12 for 20 months . But i need something as shown in the matrix above .

FOR i = 1 TO 20

Let Duration=i;

[XYZ]:

LOAD

           '12' as Value,

           'Month' & $(Duration) as Month

          AutoGenerate 1;

           

NEXT i

14 Replies
Anonymous
Not applicable
Author

Thank you very much Youssef .

I really appreciate your patience in helping me out .

Thanks a lot ,

ravi

YoussefBelloum
Champion
Champion

You're welcome

Good luck !

Anonymous
Not applicable
Author

Hello Youssef , I come back to you again with a requirement .

I have used for loop with specific number such as

For for x=1 to 4 ,  How to use For loop with column name , I mean the value 4 is in column name "Duration"


I wanted to use something like this :-

For x= 1 to Duration

How to do this ?

YoussefBelloum
Champion
Champion

It is like what we have done for the Impact_month:

[DataNew1]:

LOAD * Inline [

"Impact month"

12

];

let vImpact_Month= Peek('Impact month',0,DataNew1);

Duration_table:

LOAD * Inline [

"Duration"

4

];

let vDuration= Peek('Duration',0,Duration_table);

TRACE $(vImpact_Month);

for i=1 to 10

for x=1 to $(vDuration)

if $(i) =1 then

test:

load

$(i) as Month,

$(x) as Month2,

$(vImpact_Month) as Value

AutoGenerate 1;

ELSE

test:

load

$(i) as Month,

$(x)+($(i)-1) as Month2,

$(vImpact_Month) as Value

AutoGenerate 1;

ENDIF

NEXT x;

NEXT i;

Anonymous
Not applicable
Author

Hello Youssef,

Could you kindly help me with it .

With the reference to the above table which I have already attached  in spreadsheet .

I need to read each and every record of this table and fetch (Duration Month) and (Impact Month Value )

I have written a code kindly check the script and please do see comments .

[Project1]:
LOAD
      "Product Line",
    "Complexity Level",
    Complexity,
    "Projects Per Month",
    "Flow3 Hrs per",
    "Average Flow3Hrs",
     "Duration (Month)",
    "Impact month"


FROM [lib://documnets/Complexity.xlsx]
(ooxml, embedded labels, header is 1 lines, table is Model);

For n= 1 to $(vDATA_COUNT)-1    // Should  read all the rows of the table  . Is it correct ?


let vDATA_COUNT = NoOfRows('Project1');
Let vProductlines=Peek('Product Line',Project1,$(n));
let vcomplexity=Peek('Complexity Level',Project1,$(n));
Let vDurationMonthFlow3=Peek("Duration (Month)",,Project1,$(n));
let vImpactmonthFlow3=Peek('Impact month',Project1,$(n));

    For i=1 to 36   // Need Total months as 36
    
     For x=1 to $(vDurationMonthFlow3)   // Should read through all record values of ("Duration (Month)"


     if $(i) =1 then

         test:
          load
          $(i) as Month,
          $(x) as Month2,
          $(vFlow3Impact_Month) as value   // Should read all record values of 'Impact month'
          AutoGenerate 1;
   
     ELSE
      test:
          load
          $(i) as Month,
          $(x)+($(i)-1) as Month2,
            $(vFlow3Impact_Month) as value   // Should read all record values of 'Impact month'

 
          AutoGenerate 1;
     ENDIF
    
     NEXT x;
   

Next i ;

Next n;

This code is perfect to my requirements . Its just That it needs some correction specially For Loop

Finally I need only Value and Month2 to draw my Line curve .

Thanks,

Ravi