Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
hjm35055
Partner - Contributor III
Partner - Contributor III

Load script only if file exists?

Hi,

I am loading forecasts into my app and we do not always have a Q1 forecast.  I was wondering if there is a way to create an IF statement or something that only loads the script if it can find a file containing "Q1" and "fact"?

I am pretty new to Qlik so thanks in advance!

1 Solution

Accepted Solutions
kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi,

what is happening here is it is trying to find if the file exists or not.

So the qvdcreatetime() takes the filename with path, so if you have QVD in the same location where your qvw is located you dont need the path, but if its not in same folder then you need path.

So try this.

IF(NOT isNull(qvdCreateTime('QVDPATH\EDB Raw Q3 Forecast Fact.qvd'))) THEN

LOAD *

FROM

(qvd);

END IF


Regards,

Kaushik Solanki

Please remember to hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!

View solution in original post

9 Replies
kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi,

Do you have a separate file for Q1 forecast or its a value in your forecast field?

Regards,

Kaushik Solanki

Please remember to hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!
hjm35055
Partner - Contributor III
Partner - Contributor III
Author

All of the forecasts are separate QVDs. So 4 separate QVDs.

kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

So you want to load entire 4 QVDs only when the Q1 forecast is there?

Regards,

Kaushik Solanki

Please remember to hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!
hjm35055
Partner - Contributor III
Partner - Contributor III
Author

No.  If Q1 QVD exists, I want to load it.  If not, skip script. The other 3 are loaded regardless if Q1 is there or not.

Thank you,

kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi,

You can try loading all QVD at one go like below.

LOad * from c:\Forecast*.qvd(Qvd);

Here * will take all QVDS which is named as ForecastQ1,ForecastQ2 and so on.

If this doesnt suit your requirement then you can write a statement like below.

IF (NOT isNull(qvdCreateTime('myqvdfile.qvd'))) THEN
    LOAD * FROM myqvdfile.qvd (qvd);
END IF


Regards,

Kaushik Solanki

Please remember to hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!
hjm35055
Partner - Contributor III
Partner - Contributor III
Author

Hi,

I am having trouble getting this to work.  I am trying to test it with a Quarter I have to see if it will load but nothing is happening.  Below is my script

IF(NOT isNull(qvdCreateTime('EDB Raw Q3 Forecast Fact.qvd'))) THEN

LOAD *

FROM

(qvd);

END IF

MayilVahanan

Hi

Try like this

LET vListqvdexists=isnull(QvdCreateTime('urpath\Filename.qvd'));  // if qvd exists then 0 else -1

//if Qvd is exist then Delta loading Else Initial Loading.


if $(vListqvdexists)=0 THEN

LOAD *

FROM

(qvd);

END IF

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.
sasiparupudi1
Master III
Master III

Please try full path of the qvd

IF IsNull(FileSize('Z:\Qlikview_EDB\EDB Data\QVD\EDB Raw Q3 Forecast Fact.qvd'))=0 THEN

LOAD *

FROM

(qvd);

END IF

kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi,

what is happening here is it is trying to find if the file exists or not.

So the qvdcreatetime() takes the filename with path, so if you have QVD in the same location where your qvw is located you dont need the path, but if its not in same folder then you need path.

So try this.

IF(NOT isNull(qvdCreateTime('QVDPATH\EDB Raw Q3 Forecast Fact.qvd'))) THEN

LOAD *

FROM

(qvd);

END IF


Regards,

Kaushik Solanki

Please remember to hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!