Skip to main content
Announcements
Qlik Introduces a New Era of Visualization! READ ALL ABOUT IT
cancel
Showing results for 
Search instead for 
Did you mean: 
Jdd
Contributor
Contributor

Why is my loop executing only once ?

Hi everyone,

I have a folder with the years 2020, 2021, 2022 and they're sorted by week inside (Week 1 to 53). When I run this script it seems like it's loading only the year 2021 out of these three years and I don't get why. I've been using qlik for only a week now and would really apreciate any kind of help.

Regards Jdd.

 

 

Let deb=0;
Let fin=Year(Today(1))-2020;

 

FOR Each dir in DirList('lib://Accès/Commandes/Années/*')

Let Ann=Year(Today(1))-deb;
Let vCount=0;

For Each vDir in DirList('lib://Accès/Commandes/Années/$(Ann)/*')
LET vCount = $(vCount)+1;
Next vDir;

Let Sem=vCount;

Do while (Sem>=53-vCount+1)

[TAB Semaine$(Sem)]:
LOAD

FROM [lib://Commandes/Années/$(Ann)/Semaine$(Sem)/*.xlsx] 
(ooxml, embedded labels, header is 3 lines, table is Etat);

Let Sem=Sem-1;

Loop;
Let deb=deb+1;

Next dir;

 

1 Reply
Andrew_Delaney
Support
Support

Is this the complete code for the loops? For example I can see you define a fin variable but do not reference it elsewhere.

Qlik Sense does feature tools to help you debug code, include the ability to step through your load script, maybe this would be the best place to start https://help.qlik.com/en-US/sense/November2021/Subsystems/Hub/Content/Sense_Hub/LoadData/debug-data-...