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: 
heij1421
Partner - Creator
Partner - Creator

How to check if multiple QVD's exists

Hi all,

I have a question and I hope someone can help.

Within a map I can have 0, 1, or multiple files with a name ending with 'projectactuals', so 123_projectactuals.qvd, 456_projectactuals, etc. Within a model-qvd I want to load these QVD's BUT ONLY IF THEY EXIST.

This means LOAD 'D:\DATA\*_projectactuals.qvd' will return an error when the file does not exist.So I want to check if files ending with 'projectactuals' exist.

When I use the following statement it works fine:

LET vListQVDExistsProjectactuals = NOT isnull(QVDCreateTime('D:\Data\123_Projectactuals.qvd'));
IF $(vListQVDExistsProjectactuals) THEN LOAD...

However there can multiple files all ending with 'projectactuals' and the prefix '123' is random.

I have tried  LET vListQVDExistsProjectactuals = NOT isnull(QVDCreateTime('D:\Data\*_Projectactuals.qvd'));

but that doesn't work as the variable probably wants to have 1 unique file name and the * (star) is within the quotes, so this doesn't work.

Please help.

1 Solution

Accepted Solutions
jagan
Luminary Alumni
Luminary Alumni

Hi,

Try like this

SET ERRORMODE = 0;

Test:

LOAD

Count(DISTINCT FileName()) AS Files

FROM D:\DATA\*_projectactuals.qvd (qvd);

LET vFileCount = Alt(Peek('Files'), 0);

SET ERRORMODE =1;

Regards,

Jagan.

View solution in original post

3 Replies
vivek_niti
Partner - Creator
Partner - Creator

Hi,

Use the following before "LOAD 'D:\DATA\*_projectactuals.qvd'"

SET ERRORMODE = 0;

This will not prompt for any error while reloading.

Regards,

Vivek

jagan
Luminary Alumni
Luminary Alumni

Hi,

Try like this

SET ERRORMODE = 0;

Test:

LOAD

Count(DISTINCT FileName()) AS Files

FROM D:\DATA\*_projectactuals.qvd (qvd);

LET vFileCount = Alt(Peek('Files'), 0);

SET ERRORMODE =1;

Regards,

Jagan.

heij1421
Partner - Creator
Partner - Creator
Author

Great, this works. Thanks guys.