Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Connect 2026 Agenda Now Available: Explore Sessions
cancel
Showing results for 
Search instead for 
Did you mean: 
Gethyn
Creator
Creator

Check for existing .qvd file in load script.

Hi Everyone,

I have a QlikView script which loads data from a stored procedure in Clarity and then saves the data in a .qvd file. Previously I was incrementally adding to this one, now very large, .qvd file on a daily basis. I have now decided to try to automatically create separate .qvd files for each month to make things easier if anything goes wrong with the reload process on the server at any time.

I have the following script, which works great so long as I already have a .qvd file for the current month. What I need to do is check that the file exists before trying to load it and if it doesn't then go straight to the part that runs the stored procedure.

Let vQVD = Date(MonthEnd(DayStart(now(),-1)),'MMMYYYY');

set Path = \\QlikView1\QVDocumentsE\Pharmacy\MCR Data\HCDs_$(vQVD);

HCDs:

LOAD *

FROM

$(Path).qvd

(qvd);

HCDs:

SQL exec CLARITY.dbo.SP_GO_DRUG_DISP_AND_ADMIN 'T-1', 'T-1';

Store HCDs into $(Path).qvd (qvd);

Drop Table HCDs;

So, does anyone know how to do an If...Then...Else kind of check for files in a QlikView Script?

Thanks,

Gethyn.

Labels (1)
1 Solution

Accepted Solutions
Gethyn
Creator
Creator
Author

Thanks Stefan,

I just had to make a slight variation on your script to get it to work.

Let vQVD = Date(MonthEnd(DayStart(now(),-1)),'MMMYYYY');

set Path = \\QlikView1\QVDocumentsE\Pharmacy\MCR Data\HCDs_$(vQVD);

IF not isnull(QVDCreateTime('$(Path).qvd')) Then

HCDs:

LOAD *

FROM

$(Path).qvd

(qvd);

End If

HCDs:

SQL exec CLARITY.dbo.SP_GO_DRUG_DISP_AND_ADMIN 'T-1', 'T-1';

Store HCDs into $(Path).qvd (qvd);

Drop Table HCDs;

View solution in original post

2 Replies
swuehl
MVP
MVP

You can check for QVDCreateTime():

Let vQVDExists = not isnull(QVDCreateTime('$(Path)'));

IF vQVDExists THEN

HCD:

LOAD *

...

END IF

Gethyn
Creator
Creator
Author

Thanks Stefan,

I just had to make a slight variation on your script to get it to work.

Let vQVD = Date(MonthEnd(DayStart(now(),-1)),'MMMYYYY');

set Path = \\QlikView1\QVDocumentsE\Pharmacy\MCR Data\HCDs_$(vQVD);

IF not isnull(QVDCreateTime('$(Path).qvd')) Then

HCDs:

LOAD *

FROM

$(Path).qvd

(qvd);

End If

HCDs:

SQL exec CLARITY.dbo.SP_GO_DRUG_DISP_AND_ADMIN 'T-1', 'T-1';

Store HCDs into $(Path).qvd (qvd);

Drop Table HCDs;