Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Only at Qlik Connect! Guest keynote Jesse Cole shares his secrets for daring to be different. Learn More!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

nested if then control statement

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

14 Replies
Not applicable
Author

Thank you Sarcich, but this is not what I want, I mean more the IF...THEN...ENDIF Clause.

Not applicable
Author

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.

Not applicable
Author

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.

flipside
Partner - Specialist II
Partner - Specialist II

That code works fine for me, could it be there is an error in Criteria A and it is actually evaluating to True?

Not applicable
Author

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.