Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

eleni_theodorid
Contributor

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
Contributor

Using If in qlikview script

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!

2 Replies
MVP
MVP

Using If in qlikview script

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
Contributor

Using If in qlikview script

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!

Community Browser