Qlik Community

Qlik Sense App Development

Discussion board where members can learn more about Qlik Sense App Development and Usage.

Highlighted
ravishinge
Contributor

Re: For loop increment by every month

Thank you very much Youssef .

I really appreciate your patience in helping me out .

Thanks a lot ,

ravi

YoussefBelloum
Esteemed Contributor

Re: For loop increment by every month

You're welcome

Good luck !

ravishinge
Contributor

Re: For loop increment by every month

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
Esteemed Contributor

Re: For loop increment by every month

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;

ravishinge
Contributor

Re: For loop increment by every month

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