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

Announcements
Qlik Connect 2026! Turn data into bold moves, April 13 -15: Learn More!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Save to CSV with if statement

Hi All,

I've got a process that is run every 10 minutes which does it thing. Now I've been asked to have an snapshot of information every 6 hours only. Instead of creating another QVD that runs every 6 hours, is there a way to Store the information every 6 hours in the document that runs every 10 minutes.

Basically I'm looking at the script and seeing if I can do something to this extent but qlikview doesn't like that.

#simplified example

If(time = 6)

{

Store Table INTO test.csv

}

Any ideas are greatly appreciated

4 Replies
johnw
Champion III
Champion III

Perhaps like this. I've not waited 6 hours to make sure it works when the file already exists, but I'd expect it to.

STORE [Test] INTO Test.qvd (QVD);

LET vNow = now(1);
LET vFile = filetime('Test.csv');
LET vHours = rangesum(now(1),-filetime('Test.csv')) * 24;

TRACE >> Now = $(vNow);
TRACE >> Test.csv created = $(vFile);
TRACE >> Hours difference = $(vHours);

IF  $(vHours) > 5.95 THEN
     STORE [Test] INTO Test.csv (TXT);
END IF 

Not applicable
Author

John, good to see you back on the community.

Not applicable
Author

Hi John,

Is it possible to do something like the below?

if(Date(now(1), 'H:mm') >= '17:00') OR (Date(now(1), 'H:mm') > '17:10') THEN

STORE Customers INTO Test.csv (TXT);

END IF

I tried it the script does not throw an error, but it does not save a file

Not applicable
Author

IF((ReloadTime()>=timestamp(Today() + maketime(5)) AND ReloadTime()<timestamp(Today() + maketime(5,10))) OR (ReloadTime()>=timestamp(Today() + maketime(17)) AND ReloadTime()<timestamp(Today() + maketime(17,50)))) THEN

STORE [Customers] INTO Test.csv (TXT);

END IF

That worked!!!