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: 
martyn_birzys
Creator
Creator

Using if condition to store into qvd

I am loading data into table, but I only want to store data into qvd (overwrite existing qvd) if the the table contains data. If the table contains no data, I want to keep the existing qvd. I am getting an error on if statement:

//load new data

StockLevels:

LOAD "ITEMS";

SQL SELECT

    "ITEMS"

FROM "PRODUCTS";

//check

if Count(Peek(ITEMS)) = 0 then

Store StockLevels into ..\QVD\StockLevels.qvd;

end if

Drop Tables StockLevels;

1 Solution

Accepted Solutions
its_anandrjs

Hi,

As i understand you want to store the data into qvd if there is data into the SQL tables otherwise do not store the QVD. Then check for no of rows in the table like

//load new data

StockLevels:

LOAD "ITEMS";

SQL SELECT

    "ITEMS"

FROM "PRODUCTS";

LET vNoofRows = NoOfRows('StockLevels');

//check

if  $(vNoofRows) > 0 then

Store StockLevels into ..\QVD\StockLevels.qvd;

end if

Drop Tables StockLevels;

Regards

Anand

View solution in original post

6 Replies
arulsettu
Master III
Master III

hi

you have to try incremental load concept

check this link

Incremental load in Qlikview

its_anandrjs

Hi,

As i understand you want to store the data into qvd if there is data into the SQL tables otherwise do not store the QVD. Then check for no of rows in the table like

//load new data

StockLevels:

LOAD "ITEMS";

SQL SELECT

    "ITEMS"

FROM "PRODUCTS";

LET vNoofRows = NoOfRows('StockLevels');

//check

if  $(vNoofRows) > 0 then

Store StockLevels into ..\QVD\StockLevels.qvd;

end if

Drop Tables StockLevels;

Regards

Anand

maxgro
MVP
MVP

if NoOfRows('StockLevels') > 0 then

     trace rows>0;

     store ...........;

endif;

Gabriel
Partner - Specialist III
Partner - Specialist III

Hi,

If I understand you. You want to store data coming from SQL into a table in QVD file if a particular table has data?

What might be worth trying is using QvdTableName.

So

     IF(QvdTableName('D:\Dir\FileName.qvd')) <> 0 THEN

      STORE blah blah

     ELSE

     exit blah blah

     ENDIF

Give that a try.

rajeshvaswani77
Specialist III
Specialist III

Please try

if  NoOfRows('StockLevels') > 0 then

Store StockLevels into ..\QVD\StockLevels.qvd;

end if

thanks,

Rajesh Vaswani