Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Optimized Load nulling out variables?!?

Hi Everyone,

I have created a loop where the first part of my loop figures out what file I want to load and the second part loads the qvd. When I determine the file (the most recently created QVD in the folder) I set a variable to be the file name. Then I load said file name using the variable.

This works for the first folder perfectly, but then for the subsequent folders the variable is always null. So I commented out the loading of the data to see what was happening and made a message box tell me what the variable is at the end of each loop. This worked perfectly. So I un-commented out the load and it broke.

Then I decided, because I was out of options, to make the load unoptimized by adding a where 1=1 clause and voila it works perfectly.

Has anyone come across this? Is it a bug? I'd really like to keep my loads optimized but if it breaks my code, I guess its not worth it.

Thanks!

Rebecca

3 Replies
ToniKautto
Employee
Employee

This most likely works just as expected. I would need to see a sample of your load script to explain why it happens. Could you please attach a QVW file containing the script?

Not applicable
Author

I agree it should work as expected, but it doesn't unless I make the loads unoptimized.

Here is the gist of the code:

ReloadFile:
LOAD 
Folder
FROM

(
biff, embedded labels, table is [Folders$]);




For vCounter = 1 to NoOfRows('ReloadFile')
Let vFolder = Peek('Folder', vCounter-1, 'ReloadFile');

FOR each File in filelist (' C:\Documents\$(vFolder)\File_ ************.qvd')

$(vFolder):
LOAD
Left(RIGHT(subfield('$(File)','\',-1), 16), 12) as Submission
AUTOGENERATE 1;
NEXT;

IF NoOfRows('$(vFolder)') > 0 THEN
Inner Join ($(vFolder))
FIRST 2
LOAD * RESIDENT $(vFolder)
ORDER BY Submission DESC;


LET vMin = Num(Peek('Submission', 0, '$(vFolder)'));
LET vMax = Num(Peek('Submission', -1, '$(vFolder)'));

/*TEST:      
Load
MsgBox('MIN = $(vMin)      MAX = $(vMax)   Folder = $(vFolder)', 'msgbox', 'OKCANCEL', 'ICONASTERISK') as x, 2 as r
autogenerate 1; */


DROP TABLE $(vFolder);                

END IF


IF (NOT isNull(qvdCreateTime('C:\Documents\$(vFolder)\File_$(vMin).qvd '))) THEN
Table:
LOAD
Column
FROM
[
C:\Documents\$(vFolder)\File_$(vMin).qvd]
(
qvd);
END IF

IF (NOT isNull(qvdCreateTime('C:\Documents\$(vFolder)\File_$(vMax).qvd'))) THEN
Table:
LOAD
Column
FROM

(
qvd);
END IF

Next vCounter;

ToniKautto
Employee
Employee

Could you share a document log from when the reload fails and one from where the reload is successful? IF you do not want to share them with the entire community, could you send them directly to me?