Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
Jogi
Contributor III
Contributor III

Double loop with if condition

Hey guys, 

Have 2 loops like: 

For i = 0 to 2

      For j = 0 to 2

            Some code

Next

Next;

and output: 

1 1
2 1
1 2
2 2

And it works perfect, but I want to generate value through those values with some condition, like i = 1 , and j should also be equal 1, do you know how to do it ? 

Desire output

1 1
2 2

 

 

Labels (1)
1 Solution

Accepted Solutions
asinha1991
Creator III
Creator III

I don't understand your requirement, if I and j has to be same, why would you use 2 loops?

you can do something like this but not sure what are you trying to achieve

set a ='';

For i = 0 to 2

      Let a =$(i);

      For j = 0 to 2

           if $(j)=a then

            Some code

Next

Next;

View solution in original post

1 Reply
asinha1991
Creator III
Creator III

I don't understand your requirement, if I and j has to be same, why would you use 2 loops?

you can do something like this but not sure what are you trying to achieve

set a ='';

For i = 0 to 2

      Let a =$(i);

      For j = 0 to 2

           if $(j)=a then

            Some code

Next

Next;