Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

how to jump into next in a FOR loop

For i=1 to 3

     if $(i)<2 then

          //jump to next

     end if;

     //code xxxxxxx

     //code yyyyyyyy

NEXT

Above is the requirement, if i=1, do nothing.

I know I can put the code xxxx/yyyyy into ELSE, any other workaround/solution?

How to do this? I tried NEXT, but I get runtime error.

8 Replies
jvitantonio
Luminary Alumni
Luminary Alumni

Just do the loop from 2 to 3

Fori = 2 to 3

code xxxxx

code yyyy

NEXT

Not applicable
Author

r u kidding me?

What I need is a keyword like CONTINUE in SQL server. I just want to know if QV has such key word or not.

jagan
Luminary Alumni
Luminary Alumni

Hi,

I didn't found such Keyword in Qlikview, so using ELSE is the best way.

Regards,

Jagan.

jvitantonio
Luminary Alumni
Luminary Alumni

No, I'm not kidding. I'm just giving you an answer for a silly question you made. From what I see in your example , doing a for frmo 2 to 3 would make the trick.

If you are so smart, you could have gone to the Qlik HELP and see that there's no CONTINUE statement for the FOR...NEXT control statement.

Next time be more respectful with the people that is investing time to help you.

christophebrault
Specialist
Specialist

Hi,

Can you take the problem by the other side like :

For i=1 to 3

     if $(i)>2 then

//code xxxxxxx

     //code yyyyyyyy

     end if;

     // do nothing

NEXT

Don't know if this can help you.

In the FOR NEXT loop, you can use the Key Word EXIT with a condition. See QlikView Manual in Script in Key Words for more information on how to use this.

Inscrivez vous à ma Newletter Qlik
DoNotMissQlik- Connect with me on Linkedin
Not applicable
Author

hi Chris,

thx, I know 'exit for unless xxxx' syntax, thank you all the same.

Hi qlikuser14,

Okay I didn't clearly explain what I need.

The 1,3, 2 are both hard coded here, for easily read code. Actually they will both be variables, $(a), $(b), etc.

The requirement is that: I need to read the status of rows one by one, if fit some condition, then execute the rest command, otherwise, jump to next row.

For example, if age <20 and salary >10000, then update the status as "good boy", otherwise, do nothing.

So maybe row 1st, 4th & 5th are "good boy", but 2nd, 3rd & 6th are not.

Is that clear?

jvitantonio
Luminary Alumni
Luminary Alumni

Ok, well I'mnot sure how your structure is, but you could do this

b:

LOAD * INLINE [

    age, salary

    19, 1001

    20, 1000

];

load

age, salary,

if(age<20 and salary >1000, 'Good boy')

Resident b;

drop table b;

Not applicable
Author

Okay I understand what you said. But that's not what I want.

As I said, the condition is dynamic.

For 1st row, age condition might be >20, for 2nd, age might be >40.

And also for salary.

Catch what I say?

So, it will take more effort to use WHERE condition to filter the uesful data. Of course I can do that, but it will be more complex.

That's the reason why I ask this question. I want to find a easy way to implement this. Right now I have already find out 3 workaround, I just want to research if there has any better solution.