Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Script for loading multiple but only required matching qvd files

Hi All, I am new in Qlik Sense. I have multiple qvd files stored in one folder. I can reload using for each loop and filelist. But according to my requirement I want to store specific file names in one variable and use that variable in for each with an other for each loop for that variable, if matches with specific file the reload file. But I am struggling with storing multiple values in one variable and using that to match with filelist values. Can anybody help me please thanks. Right now I am doing this by storing each lib path in one variable and using if statement within for each filelist loop but I want optimized code. Thanks

1 Solution

Accepted Solutions
Not applicable
Author

Hi,

Finally I am able to do like following

SET vDimPath = '[lib://Dimensions/]';

DimQVD:

LOAD * INLINE [

Name

    File1

    File2

    File3

    ];

For i=0 to NoOfRows('DimQVD')-1

LET vFile=Peek('Name',i,'DimQVD');

load * FROM $(vDimPath2)$(vFile).qvd(qvd);

Next;

Thanks for the help.

View solution in original post

7 Replies
ali_hijazi
Partner - Master II
Partner - Master II

can you please send a snippet of your script so that I follow up with your requirement?

I can walk on water when it freezes
Not applicable
Author

Thanks Ali HIjazi for you reply

Right now I am doing the way as follows

In Main section i declared variables

SET VQVDPath = '[lib://HHMQVD\]';
SET vDimPath = '[lib://Dimensions\]';
Set vDimBMem = lib://Dim\Mems.qvd;
Set vDimCert = lib://Dim\Cert.qvd;
Set vDimCHTJ = lib://Dim\joins.qvd;
Set vDimEMS = lib://Dim\EMS.qvd;

IN load section

for each File in filelist(vDimPath& '\*.qvd')
if File = vDimBMem then
load *  from [$(File)] (qvd);
end if;
if File = vDimCert then
load *  from [$(File)] (qvd);
end if;
if File = vDimEMS then
load *  from [$(File)] (qvd);
end if;
next File;

But I want to optimize it. Saving all file values ( only names) in one variable and use in nested loop check if variable matched with filelist. and load. OR any other better way u suggest. Thanks

passionate
Specialist
Specialist

Hi,

try something like this:

//Names of releavent QVDs to be loaded

NameQVD:

LOAD * INLINE [

    Name

    Location

    Product

];

For i=0 to NoOfRows('NameQVD')-1

LET vFile=Peek('Name',i,'NameQVD');

LOAD  *

FROM

(qvd);

NEXT

Not applicable
Author

Thanks

I tried something like this according to you code but i got invalid path error and couldn't resolve it.

SET vDimPath = '[lib://Dimensions\]';

DimQVD:
LOAD * INLINE [
    FileName1
    FileName2
    FileName3
    FileName4
];
For i=0 to NoOfRows('DimQVD')-1
LET vFile=Peek('FileName1',i,'DimQVD');
LOAD  *
FROM $(VDimPath)$(vFile).qvd (qvd);
Next

Please Help

passionate
Specialist
Specialist

Try using backslash in your load statement

LOAD  *

FROM $(VDimPath)& '\' &$(vFile).qvd (qvd);

Not applicable
Author

I tried and got

The following error occurred:

Invalid Path

The error occurred here:

LOAD * FROM & '\' &.qvd (qvd)

There is something wrong what vFile returns that doesn't make right path with vDimPath.

I always been able to use  LOAD * FROM $(VQVDPath)FileName.qvd(qvd);  for single file but not in for each loop.

thanks

Not applicable
Author

Hi,

Finally I am able to do like following

SET vDimPath = '[lib://Dimensions/]';

DimQVD:

LOAD * INLINE [

Name

    File1

    File2

    File3

    ];

For i=0 to NoOfRows('DimQVD')-1

LET vFile=Peek('Name',i,'DimQVD');

load * FROM $(vDimPath2)$(vFile).qvd(qvd);

Next;

Thanks for the help.