Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Not applicable

problem with if in scripting

hi,

i have this if structure in my qvd generator qvw file

if vAction=0 then

     if ...

     else

     .....

     End If

     if......

     else

     end if

End if

if vAction=-1 then

     if ...

     else

     .....

     End If

     if......

     else

     end if

End if

let's will said that vAction=-1, it should jump to the second condition but i don't know why it's continuing in the else inside the false condition (3rd line in example structure)

i've checked the code and the structure a lot of times but i cant find why it happening this...

what could be the problem??

1 Solution

Accepted Solutions
Not applicable

Re: problem with if in scripting

switch vAction

case 1

script

case -1

script

default

script

end switch

Fabrice

6 Replies

Re: problem with if in scripting

Use if vAction -=1 then

Not applicable

Re: problem with if in scripting

hi Manish i'm using it already,

flipside
Valued Contributor II

Re: problem with if in scripting

What you have is two completely separate Nested If statements, so it is working correctly. Your line three is running when Lines 1 and 2 have evaluated false and because it is an else statement runs for any value not already caught by lines 1 and 2. Depending on what you need to do, you need to re-structure your statements.

flipside

Not applicable

Re: problem with if in scripting

Carlos,

Are you sure about the value of vAction ? You can nest several if statements without any problem.

Did you trace it through the debugger ?

Fabrice

Not applicable

Re: problem with if in scripting

hi flipside,

i need to run several if conditions depending of a bigger condition (vAction) something like a case statement

simplifying the question...

how i could do a case statement in Qlikview?

Not applicable

Re: problem with if in scripting

switch vAction

case 1

script

case -1

script

default

script

end switch

Fabrice

Community Browser