Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Conditional script load

Good morning,

I would like to know if there is a way to do a test in a load script.e.g, I want only load a table if the last refresh date is different than the date of today.

Something like :

IF reloadtime() <> today then

table1 :

load ....

from ...

;

end if;

Thanks.

4 Replies
Not applicable
Author

Hi Jérôme


You could try something like:


//Set the variables

Let vtime = Date(ReloadTime(),'DD/MM/YYYY');

Let vtoday = Date(now(),'DD/MM/YYYY');

LET vFilePath = 'C:\Test';

//If the 2 dates are the same, do nothing

if $(vtime) = $(vtoday) then

ENDIF

//If the 2 dates differ, load the table (and store into a QVD)

If $(vtime) <> $(vtoday) then

TEST:

LOAD

* Inline [

FieldOne, FieldTwo

Test1, Test2

Test3, Test4

];

Store TEST into $(vFilePath)\TEST.qvd(qvd);

ENDIF;


Let me know if that doesn't help and I'll see if I can think more for you.


Justine

Not applicable
Author

Hi Justine,

Thanks for this syntax. It works. But now my table is empty.

I thought that the old values were still there. But no.

I just would keep older values.

Thanks.

Not applicable
Author

Hello

I've had a very quick look.  Do you have somewhere that you can keep qvd files? My preference would be to use a qvd and then do the following:

Let vtime = Date(ReloadTime(),'DD/MM/YYYY');

Let vtoday = Date(now(),'DD/MM/YYYY');

LET vFilePath = 'C:\Test';

// If the dates are equal, load the existing qvd back into the table

if $(vtime) = $(vtoday) then

TEST:

Load * from $(vFilePath)\TEST.qvd(qvd);

ENDIF

// If dates are not equal, Load whatever you need here

If $(vtime) <> $(vtoday) then

TEST:

LOAD

* Inline [

FieldOne, FieldTwo

Test1, Test2

Test3, Test4

];

//Store new data into the qvd

Store TEST into $(vFilePath)\TEST.qvd(qvd);

ENDIF;

I'm not sure if there's a way of retaining data in an actual table in a script - hence the use of a reload from a QVD. This could have an impact on storage space etc though if your datasets are large. It could also take longer to run the script.

Hopefully, someone will post on here with some code that will allow the table to retain the data that was already in it - that would be really useful. In the meantime, the above solution will work, but is more clumsy.

Let me know how you get on.

Justine

qlikpahadi07
Specialist
Specialist

Hi Jerome,

if you have more than 2 tables in QVW then its not possible to refresh one and load the second as previous data.

QVW will refresh the entire data

if I am getting your point then you can search for Incremental load.