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: 
kamielrajaram
Creator III
Creator III

IF ... THEN ... END IF issue

Good day All,

Please could you advise on the following. I have a document that is scheduled daily. In the script I have section that saves a table to csv, this should only happen on a Monday. This always fails on a Monday, but if i reload manually it all works fine. this is my script

If WeekDay(Today()) = 'Mon' Then

LET vDStart = '2011/04/10';

LET vDEnd = Date(Today()-1);

TMPTable:

Load * Resident Table;

Table1:

Load * Resident TMPTable

Where

Date(Calendar) >= '$(vDStart)' and

Date(Calendar) <= '$(vDEnd)';

Drop Table TMPTable;

STORE Table1 into 'QVDPath:\FileName.csv'(txt);

DROP Table Table1;

End If;

Thank you in advance

Kamiel

Good day, Thnak you for all your help. After some digging,the error was that I needed to put the full unc path in the store section. I may have not explained that I was storing the csv file to a mapped drive.

Thank you

9 Replies
giakoum
Partner - Master II
Partner - Master II

Any error messages or sample application?

kamielrajaram
Creator III
Creator III
Author

In th log file, it just has general script failure

giakoum
Partner - Master II
Partner - Master II

How do you automatically reload? server or batch file? If server, please check the server reload log for errors as well.

flipside
Partner - Specialist II
Partner - Specialist II

If the log files don't give you exactly what you want, then I have previously implemented bespoke logging by dumping variable states to a log like this ...

SUB Log (SeqNo,Message)

LET vSeqNo = SeqNo;
LET vlogTime =  Now();
LET vMessage = Message;

IF NOT(IsNull(vMessage)) THEN
  Logging:
  LOAD
   '$(vSeqNo)' as SeqNo,
   '$(vlogTime)' as logTime,
   '$(vMessage)' AS logMessage
   AUTOGENERATE 1;
ENDIF

Store Logging into Log.txt (txt);

ENDSUB;


If Weekday(Today())='Tue' Then 
         CALL Log('001',Weekday(Today()));

Let vDStart = '10/04/2011';  CALL Log('002','$(vDStart)');
Let vDEnd = Date(Today()-1); CALL Log('003','$(vDEnd)');
Let vFail = Evaluate(100/0); CALL Log('004','$(vFail)'); // divide by zero error

End If;

This might help trap the exact point of failure.

flipside

kamielrajaram
Creator III
Creator III
Author

Hi,

this precess is automated.In the event viewer -document failed to reload error count =3

Not applicable

kamielrajaram,

are you sure that in the environment where you reload application (server presumably), you have day namings like 'Mon', 'Tue', etc. and date format 'YYYY/MM/DD' and not any other (e.g. in native language)? Do you have according SET statements in your script?

kamielrajaram
Creator III
Creator III
Author

Hi Dmitry,

this is in my script

Set DayNames = 'Mon;Tue;Wed;Thu;Fri;Sat;Sun';

Set DateFormat = 'YYY/MM/DD';

Not applicable

Why do you have YYY (3 letters) instead of more common YYYY (4 letter) ?

kamielrajaram
Creator III
Creator III
Author

Sorry was a typo, it is YYYY/MM/DD