Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

heij1421
New Contributor III

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
MVP
MVP

Re: How to check if multiple QVD's exists

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.

3 Replies
vivek_niti
Contributor

Re: How to check if multiple QVD's exists

Hi,

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

SET ERRORMODE = 0;

This will not prompt for any error while reloading.

Regards,

Vivek

MVP
MVP

Re: How to check if multiple QVD's exists

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
New Contributor III

Re: How to check if multiple QVD's exists

Great, this works. Thanks guys.

Community Browser