Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
rassanbekov
Partner - Contributor
Partner - Contributor

Loop for Qlikview

Hello! I need to write a loop in Qlikview to use formula n times and generate output in separate field n times.

I did it in excel but For function does not work for me in Qlikview.

Could you please help with script?

You can access to macros in excel for further details.

1 Solution

Accepted Solutions
petter
Partner - Champion III
Partner - Champion III

You can try this load script - it is based on your spreadsheet's Input1 and Input 2:

INPUT:

LOAD RowNo() AS W#,* INLINE [

D6 E6

100 12

200 3

20 5

3000 0,500

60 0,125

188 1

11 666 1

1 400 1

300 1

111 1

1 255 12

500 2

10 2

200 2

4 000 2

5 000 3

50 3

456 3

780 3

800 3

500 4

400 4

200 4

100 4

100 4

100 5

100 5

100 5

100 5

100 5

100 5

3000 6

144 6

155 6

1 000 6

900 6

900 7

900 7

900 7

900 7

900 7

900 7

500 8

5 000 8

10 000 8

10 000 8

10 000 9

100 9

200 9

300 9

400 9

500 10

] (delimiter is \t);

FOR i=1 TO 20

  LOAD

    $(i) AS Sim#,

    Sum(J6*G6) AS Consequences

  ;

  LOAD

    G6,  // InputProduct

    IF(RAND()>F6,0,1) AS J6 // Random Value

  ;

  LOAD

    IF(E6>=4,0.95,E6/4) AS F6, //Probability,

    IF(E6>4,D6*E6/4,D6) AS G6  //InputProduct

  RESIDENT

    INPUT

;

NEXT

The three LOAD statements roll up into one single load with just some intermediate calculations in the load at line #67 and line #63. It is called PRECEDING load. They sort of piggy-tail.

View solution in original post

1 Reply
petter
Partner - Champion III
Partner - Champion III

You can try this load script - it is based on your spreadsheet's Input1 and Input 2:

INPUT:

LOAD RowNo() AS W#,* INLINE [

D6 E6

100 12

200 3

20 5

3000 0,500

60 0,125

188 1

11 666 1

1 400 1

300 1

111 1

1 255 12

500 2

10 2

200 2

4 000 2

5 000 3

50 3

456 3

780 3

800 3

500 4

400 4

200 4

100 4

100 4

100 5

100 5

100 5

100 5

100 5

100 5

3000 6

144 6

155 6

1 000 6

900 6

900 7

900 7

900 7

900 7

900 7

900 7

500 8

5 000 8

10 000 8

10 000 8

10 000 9

100 9

200 9

300 9

400 9

500 10

] (delimiter is \t);

FOR i=1 TO 20

  LOAD

    $(i) AS Sim#,

    Sum(J6*G6) AS Consequences

  ;

  LOAD

    G6,  // InputProduct

    IF(RAND()>F6,0,1) AS J6 // Random Value

  ;

  LOAD

    IF(E6>=4,0.95,E6/4) AS F6, //Probability,

    IF(E6>4,D6*E6/4,D6) AS G6  //InputProduct

  RESIDENT

    INPUT

;

NEXT

The three LOAD statements roll up into one single load with just some intermediate calculations in the load at line #67 and line #63. It is called PRECEDING load. They sort of piggy-tail.