Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
datanibbler
Champion
Champion

Issue with an IF_THEN_ELSE loop

Hi,

i am facing a strange issue:

There is a loop, based on a small table loaded from excel that has six entries - inside the loop over this table,

there is an IF_THEN processing two of those entries, then there is an ELSEIF_THEN (the new part) processing one more of those values - because out of the four remaining ones, I have to treat one differently from the rest - and last there is an ELSE part processing the remaining three.

<=> For some reason, I am having trouble with the middle part, the ELSEIF_THEN, although the syntax is relatively easy.

I specify the specific value that should be in my counting variable (a string) for this part to be executed and by putting an EXIT before the loop and building a test_field in that little table I have made quite sure that that string really exists there and there are no hidden characters or other stuff.

I keep on trying, so it's kind of hard to say what I did last, but for some reason the loop seems to never enter that middle part. I have to look through the log exactly to find out what is or isn't done in every iteration.

Maybe someone can give me a hint on what I am doing wrong here?

Thanks a lot!

Best regards,

DataNibbler

1 Solution

Accepted Solutions
datanibbler
Champion
Champion
Author

Okay,

I am trying something different now: I am not putting in an ELSEIF_THEN, but instead, in the ELSE part I am building an IF() in the LOAD so that one field is loaded in a different manner for one out of those four values. Let's see if that works - for the moment I have deleted all five other values from that small table so that the loop should run only once and only that one value I am interested in should be processed. Once that works, I can restore the rest.

P.S.: Seems to work - now I'll restore the remaining values and we'll see ...

@ Sunny

My script used to look like this: There was a "FOR i=0 to NoOfRows('Partnerrolle'))-1" loop over that table - six entries.

As I said, the first IF_THEN part queried the variable made with PEEK() for two of those values;

The ELSEIF_THEN which I wanted to put in would have queried the variable for one more value (string, in quotes);

- The final ELSE part would have dealt with everything else without further specifying the three remaining values.

View solution in original post

4 Replies
sunny_talwar

What is your script look like?

datanibbler
Champion
Champion
Author

Okay,

I am trying something different now: I am not putting in an ELSEIF_THEN, but instead, in the ELSE part I am building an IF() in the LOAD so that one field is loaded in a different manner for one out of those four values. Let's see if that works - for the moment I have deleted all five other values from that small table so that the loop should run only once and only that one value I am interested in should be processed. Once that works, I can restore the rest.

P.S.: Seems to work - now I'll restore the remaining values and we'll see ...

@ Sunny

My script used to look like this: There was a "FOR i=0 to NoOfRows('Partnerrolle'))-1" loop over that table - six entries.

As I said, the first IF_THEN part queried the variable made with PEEK() for two of those values;

The ELSEIF_THEN which I wanted to put in would have queried the variable for one more value (string, in quotes);

- The final ELSE part would have dealt with everything else without further specifying the three remaining values.

sunny_talwar

okay

datanibbler
Champion
Champion
Author

Thanks for your willingness to help, Sunny!

I would still like to know why it didn't work before - but that's not so critical.

That "secondary distinction" within the ELSE part seems to work.

Everything is nice and unique now as it should be. That makes working with the data a lot easier.

Best regards,

DataNibbler