Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Question: Can IF..THEN.....ELSE...ENDIF control statements be nested in QlikView.
I am trying to catch an error, and take actions depending on criteria
basics of script are:
IF condition1 THEN
IF Condition2 THEN
Do one thing here - eg. handle error and continue
ELSE
Do something else here - eg exit script
ENDIF
ELSE
Do something else here
ENDIF
What appears to happen is that when condition 1 in the outer IF is not met, the ELSE from the Inner IF is executed rather than the ELSE for the outer IF
The script:
IF condition1 THEN
IF Condition2 THEN
Do one thing here - eg. handle error and continue
ELSE
Do something else here - eg exit script
ENDIF
ELSE
Do something else here
ENDIF
is absolutely correct, the error can be related to the things you do ... one question, at the end of each instruction in IF have you written the semicolon?
Do one thing here - eg. handle error and continue;
The script:
IF condition1 THEN
IF Condition2 THEN
Do one thing here - eg. handle error and continue
ELSE
Do something else here - eg exit script
ENDIF
ELSE
Do something else here
ENDIF
is absolutely correct, the error can be related to the things you do ... one question, at the end of each instruction in IF have you written the semicolon?
Do one thing here - eg. handle error and continue;
Hi Eddie,
I haven't tried such a thing - not in Qlikview, anyway.
Maybe you could just use one IF THEN control statement and put the other one into something like e.g. a subroutine? Or, instead of nesting them (which is more elegant, of course), you could "flatten it out" and write sth like >>> IF ([condition 1] AND [condition 2]) THEN
...
ELSEIF [condition 1]
...
ELSE
...
ENDIF <<<
Try it out - in my experience from other scripting languages, you should always account for the most special case - that is likely to be true in the smallest nr. of instances - first.
Best regards,
DataNibbler
Hi Eddie
Look at the semicolon in the end of the first IF
THEN;
This can be the problem
Eduardo
Looks like the issue was to do with trying to interrogate the ScriptError and ScriptErrorDetails within the inner IF. These system variables appear to have Cleared/Reset on successful execution of the outer if....