Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
hansdevr
Creator III
Creator III

For next scripting with variables

Dear Qlik Experts,

 

Is this a possible script?

Sub Missing_dates

For vCategorie = 1 to 5

Let vCat = PEEK('Cat',$(vCategorie),Categorieen);

For vSoort = 1 to 4

Let vSrt = PEEK('Srt',$(vSoort),Soorten);

Missing_dates:
NoConcatenate
Load
Datum as Peildatum,
text($(vCat)) as Categorie,
text($(vSrt)) as Soort
Resident Calendar;

join(Totalen) load * Resident Missing_dates;
Drop table Missing_dates;



Next vSoort

Next vCategorie

endsub

 

 

 

 

I get funny errors like this:

Syntax error

Unexpected token: ')', expected one of: '(', 'ZTestw_z', 'OPERATOR_PLUS', 'OPERATOR_MINUS', 'not', 'bitnot', 'LITERAL_NUMBER', ...

Missing_dates:
NoConcatenate
Load
Datum as Peildatum,
text(>>>>>>)<<<<<< as Categorie,
text() as Soort
Resident Calendar

Labels (1)
3 Replies
mato32188
Specialist
Specialist

Hi Hans,

have you tried 

Missing_dates:
NoConcatenate
Load
Datum as Peildatum,
text('$(vCat)') as Categorie,
text('$(vSrt)') as Soort
Resident Calendar;

BR

Martin

ECG line chart is the most important visualization in your life.
hansdevr
Creator III
Creator III
Author

No, that did not work, unfortunately,

I will explain. I have two inline tables, Categorieen (filled with A, B, C, etc), and a table with Soorten, also filled with strings

 

I use the for-next loop to peek the records in these tables and use the result to fill a field in my Totalen table.

The Datum as Peildatum comes from my Master Calendar table. This way I can fill up missing dates in my Totalen table

Brett_Bleess
Former Employee
Former Employee

Hans, have you tried running this via the Edit Script Debug tool?  That is likely the best option to try to gather further information on exactly where things are failing such that you can check syntax of things, as it seems you just have a mismatch of ()'s somewhere in the code.  Sorry I do not have anything better, but here is a Design Blog post on Loops as well, not sure if there will be anything there to help or not, but worth a shot...

https://community.qlik.com/t5/Qlik-Design-Blog/Loops-in-the-Script/ba-p/1473543

Regards,
Brett

To help users find verified answers, please do not forget to use the "Accept as Solution" button on any post(s) that helped you resolve your problem or question.
I now work a compressed schedule, Tuesday, Wednesday and Thursday, so those will be the days I will reply to any follow-up posts.