Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

If statement in load script over multiple lines

Hi there,

I have an If statement in the load script with a quite long if-clause which I like to write over multiple lines for a nicer view. Something like this:

If      variable_a = 1                                   // case 1

  or  ( variable_a = 2 and variable_b = 3 )    // case 2

  or  ( variable_a = 3 and variable_b = 5 )    // case 3

then

  DO SOMETHING

else

  DO SOMETHING ELSE

endif;

Unfortunatly, it is not working like this.

Any ideas?

1 Solution

Accepted Solutions
maxgro
MVP
MVP

interesting, if you put the condition in a variable (I don't like it) it seems to work

LET variable_a=3;

LET variable_b=5;

LET test=

  variable_a = 1                                           // case 1

  or  ( variable_a = 2 and variable_b = 3 )      // case 2

  or  ( variable_a = 3 and variable_b = 5 );     // case 3

If      $(test)  then                                

  trace DO SOMETHING;

else

  trace DO SOMETHING ELSE;

endif;

View solution in original post

5 Replies
sunny_talwar

Try this with dollar sign may be:

If  $(variable_a) = 1                                   // case 1

  or  ( $(variable_a) = 2 and $(variable_b) = 3 )    // case 2

  or  ( $(variable_a) = 3 and $(variable_b) = 5 )    // case 3

alexandros17
Partner - Champion III
Partner - Champion III

It seems you cannot go ahead ...

alexandros17
Partner - Champion III
Partner - Champion III

Try with:

If      variable_a = 1    or                               // case 1

  ( variable_a = 2 and variable_b = 3 )  or   // case 2

  ( variable_a = 3 and variable_b = 5 )    // case 3

then

  DO SOMETHING

else

  DO SOMETHING ELSE

endif;

maxgro
MVP
MVP

interesting, if you put the condition in a variable (I don't like it) it seems to work

LET variable_a=3;

LET variable_b=5;

LET test=

  variable_a = 1                                           // case 1

  or  ( variable_a = 2 and variable_b = 3 )      // case 2

  or  ( variable_a = 3 and variable_b = 5 );     // case 3

If      $(test)  then                                

  trace DO SOMETHING;

else

  trace DO SOMETHING ELSE;

endif;

Not applicable
Author

Hey Massimo,

you are right, this is not very elegant , but nevertheless it is working and helps me to write my code more clearly arranged.

Thanks a million

u.