Qlik Community

QlikView App Dev

Discussion Board for collaboration related to QlikView App Development.

cancel
Showing results for 
Search instead for 
Did you mean: 
rustyfishbones
Master II
Master II

IF THEN ELSE Help

Hi All,

I have the following 3 variables

SET iProduct = 1;

SET iCustomer = 0;

SET iUnit = 1;

I want to create a Sub Routine that will look at the value, and if the Value is 1 then read from the Script file.

I can only get it working for the first file which is product.qvs

Here is what I have but it's not working

SUB Extraction

IF $(iProduct) = 1   THEN

     $(Must_Include=$(includePath)product.qvs);

   

     ELSEIF$(iCustomer) = 1 THEN

  $(Must_Include=$(includePath)customer.qvs);

  

END IF

END SUB

I will have about 15 tables and I want to create a nested IF THEN ELSE Statement to load the files if the Value is equal to 1

Thanks

Alan

1 Solution

Accepted Solutions
rustyfishbones
Master II
Master II
Author

Hi All,

I got it working by using Separate IF Statement within the routine

like the following

SUB Extraction

IF $(iProduct) = 1   THEN

     $(Must_Include=$(includePath)product.qvs);

    

END IF

IF $(iCustomer) = 1   THEN

     $(Must_Include=$(includePath)customer.qvs);

    

END IF

IF $(iUnit) = 1   THEN

     $(Must_Include=$(includePath)unit.qvs);

    

END IF

END SUB

View solution in original post

5 Replies
PrashantSangle

Hi,

Instead of Creating variable with SET keyword

You can try with LET Keyword

Hope it will solve your issue.

Regards

Great dreamer's dreams never fulfilled, they are always transcended.
rustyfishbones
Master II
Master II
Author

Hi All,

I got it working by using Separate IF Statement within the routine

like the following

SUB Extraction

IF $(iProduct) = 1   THEN

     $(Must_Include=$(includePath)product.qvs);

    

END IF

IF $(iCustomer) = 1   THEN

     $(Must_Include=$(includePath)customer.qvs);

    

END IF

IF $(iUnit) = 1   THEN

     $(Must_Include=$(includePath)unit.qvs);

    

END IF

END SUB

rustyfishbones
Master II
Master II
Author

If anyone has a better way of doing this please share

PrashantSangle

Hi,

Have try writing Else if seperately

like,

SUB Extraction

IF $(iProduct) = 1   THEN

     $(Must_Include=$(includePath)product.qvs);

   

     ELSE IF $(iCustomer) = 1 THEN

       $(Must_Include=$(includePath)customer.qvs);

      End If 

END IF

END SUB

Regards

Great dreamer's dreams never fulfilled, they are always transcended.
rustyfishbones
Master II
Master II
Author

Hi Max,

I tried that but it would only ever read the first table/script file

But thanks anyway

Regards

Alan