2 Replies Latest reply: Jan 30, 2015 6:11 AM by Marcus Sommer RSS

    Loop in QlikView SCript will not work

      I Try to make a Loop in my QlikView Script but it will not work.

      Can someone tell my what i do wrong.

       

      UITVOERDERS:

      LOAD

       

       

        SUBFIELD(REPLACE(Subfield(item_lijst,';',1), ',', ';'), ';',1) AS Uitvoerder,

        SUBFIELD(REPLACE(item_code_lijst, ',', ';'), ';',1) AS Uitvoerder_Code

        ;

      SQL SELECT *

      FROM mtc_rubriek

      WHERE rubcode = 'PROJ_006';

       

       

      UITVOERDERS:

      LOAD

        SUBFIELD(REPLACE(Subfield(item_lijst,';',1), ',', ';'), ';',2) AS Uitvoerder,

        SUBFIELD(REPLACE(item_code_lijst, ',', ';'), ';',2) AS Uitvoerder_Code

        ;

      SQL SELECT *

      FROM mtc_rubriek

      WHERE rubcode = 'PROJ_006';

       

       

      UITVOERDERS:

      LOAD

        SUBFIELD(REPLACE(Subfield(item_lijst,';',1), ',', ';'), ';',3) AS Uitvoerder,

        SUBFIELD(REPLACE(item_code_lijst, ',', ';'), ';',3) AS Uitvoerder_Code

        ;

      SQL SELECT *

      FROM mtc_rubriek

      WHERE rubcode = 'PROJ_006';

       

       

      This is the script total write down but than 10 times.

       

      I Want to make a loop of it.

       

      UITVOERDERSAANTAL:

      LOAD

      COUNT(DISTINCT(UitvoerderAantal)) AS MAXUITVOERDERS;

      LOAD

        SUBFIELD(REPLACE(Subfield(item_lijst,';',1), ',', ';'), ';') AS UitvoerderAantal

        ;

      SQL SELECT *

      FROM mtc_rubriek

      WHERE rubcode = 'PROJ_006';

       

       

      LET V_MAXUITVOERDERS = MAXUITVOERDERS+1;

      DROP TABLE UITVOERDERSAANTAL;

      FOR i =1 to $(V_MAXUITVOERDERS)-1

      LET LOOP = $(i);

       

       

       

       

      //EXIT SCRIPT;

       

       

      UITVOERDERS:

      LOAD

        SUBFIELD(REPLACE(Subfield(item_lijst,';',1), ',', ';'), ';',$(LOOP)) AS Uitvoerder,

        SUBFIELD(REPLACE(item_code_lijst, ',', ';'), ';',$(LOOP)) AS Uitvoerder_Code

        ;

      SQL SELECT *

      FROM mtc_rubriek

      WHERE rubcode = 'PROJ_006';

      //STORE UITVOERDERS INTO Q:\Rapportages\Peter\UITVOERDER.QVD;

       

       

      NEXT i

       

       

      //DROP TABLE UITVOERDERSAANTAL;

       

       

      EXIT SCRIPT;

       

      BUT it doesn't work, can somebody help my with this question?