Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello everyone,
I want to nest the if...then statement like
if ... then
do something
if... then
do something
endif
else
do something
endif
The problem is: there are two endifs and qlikview stops at the first one and doesn't go futher. Does anyone have a solution for this issue?
Many thanks in advance
Thank you Sarcich, but this is not what I want, I mean more the IF...THEN...ENDIF Clause.
For the syntax outside of the load statement it is just:
IF Criteria A THEN
IF Criteria 1 THEN
Set vSomeVariable = 'A1';
ELSEIF Criteria 2 THEN
Set vSomeVariable = 'A2';
ELSE
Set vSomeVariable = 'A#';
END IF
ELSEIF CriteriaB THEN
IF Criteria 1 THEN
Set vSomeVariable = 'B1';
ELSEIF Criteria 2 THEN
Set vSomeVariable = 'B2';
ELSE
Set vSomeVariable = 'B#';
END IF
ELSE
Set vSomeVariable = 'XX';
END IF
As flipside said, you have probably missed a semicolon or something like that.
Do I have to use the complete clause? I tried with the following syntax:
IF Criteria A THEN
IF Criteria 1 THEN
Set vSomeVariable = 'A1';
ELSEIF Criteria 2 THEN
Set vSomeVariable = 'A2';
ELSE
END IF
ELSEIF CriteriaB THEN
IF Criteria I THEN
Set vSomeVariable = 'B1';
ELSEIF Criteria II THEN
Set vSomeVariable = 'B2';
ELSE
END IF
ELSE
END IF
I have only two criteria in each clause, so it's empty by else. The criteria A is not fulfilled, instead of comparing criteria B, it goes to criteria 2. I just don't understand why.
That code works fine for me, could it be there is an error in Criteria A and it is actually evaluating to True?
Hi filpside,
I tried the IF...Then statement with some simple code, it worked too. I think there must be some errors in the criteria or in the other code as you said.