# QlikView App Dev

Discussion Board for collaboration related to QlikView App Development.

Announcements
Action-Packed Learning Awaits! QlikWorld 2023. April 17 - 20 in Las Vegas: REGISTER NOW
cancel
Showing results for
Did you mean:
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.

1 Solution

Accepted Solutions
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
\$(i) AS Sim#,
Sum(J6*G6) AS Consequences
;
G6,  // InputProduct
IF(RAND()>F6,0,1) AS J6 // Random Value
;
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.

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
\$(i) AS Sim#,
Sum(J6*G6) AS Consequences
;
G6,  // InputProduct
IF(RAND()>F6,0,1) AS J6 // Random Value
;