2 Replies Latest reply: Apr 25, 2012 10:23 AM by Eleni Theodoridou RSS

    Using If in qlikview script

    Eleni Theodoridou

      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

        • Using If in qlikview script
          Steve Dark

          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/

            • Using If in qlikview script
              Eleni Theodoridou

              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!