Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements

Breathe easy -- you now have more time to plan your next steps with Qlik!
QlikView 11.2 Extended Support is now valid through December 31, 2020. Click here for more information.

Not applicable

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?

1 Solution

Accepted Solutions
Peter_Cammaert
Not applicable

Re: Loop in QlikView SCript will not work

One remark:

  • Change your variable assignment to LET V_MAXUITVOERDERS = peek('MAXUITVOERDERS')+1;

Best,

Peter

2 Replies
Peter_Cammaert
Not applicable

Re: Loop in QlikView SCript will not work

One remark:

  • Change your variable assignment to LET V_MAXUITVOERDERS = peek('MAXUITVOERDERS')+1;

Best,

Peter

marcus_sommer
Not applicable

Re: Loop in QlikView SCript will not work

I'm not quite sure what you are trying to do but I think you don't need these complex loop then by using from subfield within a load and without the third parameter it will automatically loop through these field and generate for each item a record.

- Marcus