Qlik Community

Qlik Sense Cloud Discussions

Highlighted
Not applicable

Check if QVD File Exists, if it exists, load it, if not, make a full search on the DB

Hello,

I need help troubleshooting this script:

// Check if QVD File Exists, if exists load it if not make a full search on the DB

LET vQVDexists = isnull(QvdCreateTime('lib://ConfigData/ROIMEDIA.qvd'));

if $(vQVDexists) = 0 then

  TRACE( 'QVD Exists' );

    Main:

  LOAD * FROM 'lib://ConfigData/ROIMEDIA.qvd' (qvd);

    LET vMaxDate = Peek('Date',-1);

    LET vMaxTime = Peek('Time',-1);

Else

  TRACE( 'QVD Do not Exists' );

    SET vMaxDate = ;

    SET vMaxTime = ;

end if;

TRACE 'Max Date: ' $(vMaxDate);

TRACE 'Max Time: ' $(vMaxTime);

I get the error on the attached image when I try to load.

 photo Qlik picture_zpsbijyx0cx.png

Tags (2)
3 Replies
mwoolf
Honored Contributor II

Re: Check if QVD File Exists, if it exists, load it, if not, make a full search on the DB

Try using something like:

LET vQVDexists = if(FileSize('lib://ConfigData/ROIMEDIA.qvd') > 0, -1, 0);

rsvebeck
Valued Contributor

Re: Check if QVD File Exists, if it exists, load it, if not, make a full search on the DB

This works:

//Use alt() function to make sure the variable always has a value (avoiding null problem)
Let vQvdCreatedTime = alt(QvdCreateTime('D:\Qlikview\myQVDFile.QVD'),0);

if vQvdCreatedTime > 0 then

trace File Exists!;
//Continue....

else
trace File Does not Exist!;
end if;

Best Regards

Robert

Svebeck Consulting AB

CGilQlik
New Contributor II

Re: Check if QVD File Exists, if it exists, load it, if not, make a full search on the DB

Hello everyone!

Here is a simple solution from smoon63‌:

"To make the variable act as a Boolean value, add "not" before isnull:

LET vListQVDExists = not isnull(QVDCreateTime('File.qvd'));

Now you can use

     IF $(vListQVDExists) THEN...

instead of

     IF $(vListQVDExists) = 0 THEN... "

Original post: Re: How can I check if a file exists ?

Regards!

Community Browser