Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

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
MVP
MVP

Re: If statement in load script over multiple lines

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;

5 Replies

Re: If statement in load script over multiple lines

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

Re: If statement in load script over multiple lines

It seems you cannot go ahead ...

Re: If statement in load script over multiple lines

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;

MVP
MVP

Re: If statement in load script over multiple lines

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

Re: If statement in load script over multiple lines

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.

Community Browser