Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
eleni_theodorid
Partner - Creator
Partner - Creator

Using If in qlikview script

Could you please help me with this peace of script:

For i = 1 To $(LOOP_COUNTER)

       if i = 1  Then  SET SelectORJoin = 'Sql Select';

       else  SET SelectORJoin = 'Join (Table1) Select';

               .

               .

               .

               .

     endif

Next i;

How could we write this in qlikview script?

Thanks a lot,

Helen

1 Solution

Accepted Solutions
eleni_theodorid
Partner - Creator
Partner - Creator
Author

The problem was the THEN, without it , it works fine:

For i = 1 To $(LOOP_COUNTER)

       if i = 1  SET SelectORJoin = 'Sql Select';

       else  SET SelectORJoin = 'Join (Table1) Select';

               .

               .

               .

               .

     endif;

Next i;

Thanks a lot!

View solution in original post

2 Replies
stevedark
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi Helen,

Either with an inline join:

let SelectORJoin = if(i=1, 'SQL SELECT', 'JOIN (Table1) SELECT');

Or with an if structure like VBA:

if i = 1 then

     let SelectORJoin = 'SQL SELECT';

else

     let SelectORJoin = 'JOIN (Table1) SELECT';

end if

Note that semi colons are not required on the end of the construct lines, the one at the end of your next statement is also superfluous.

Hope that helps,

Steve

http://www.quickintelligence.co.uk/

eleni_theodorid
Partner - Creator
Partner - Creator
Author

The problem was the THEN, without it , it works fine:

For i = 1 To $(LOOP_COUNTER)

       if i = 1  SET SelectORJoin = 'Sql Select';

       else  SET SelectORJoin = 'Join (Table1) Select';

               .

               .

               .

               .

     endif;

Next i;

Thanks a lot!