Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
I'm new to Qlikview, Could anyone help me in using a 'if else' clause in the script level of Qlikview.
I want to run a SQL Query based on IF ELSE condition, the satisfied condition i want to save it in a qvd. I get a script line error as in the screen shots at IF and Else statement line. when clicked 'ok' in the error, both the SQL statements run and fetch data in Qlikview.
Example:
IF (weekday(today())='Sat')
SQL SELECT * FROM TABLE1;
ELSE
SQL SELECT * FROM TABLE2;
Here is the SQL query used in the Mysql (SQL Server) Database.
if exists (select 1 WHERE datename(WEEKDAY,GETDATE())='Monday')
SELECT * FROM TABLE1
else
SELECT * FROM TABLE2
Thanks for your help
Message was edited by: shyam kumar
It should be like below. Remove Parenthesis in your IF statement. Because, IF statement need two arguments
IF weekday(today())='Sat' THEN
SQL SELECT * FROM TABLE1;
ELSE
SQL SELECT * FROM TABLE2;
I noticed a syntax error in the query which i shared earlier (Missed THEN in the example). But However when i give a table name and store it in a qvd, it is throwing an error.
Temp:
IF (weekday(today())='Sat')
SQL SELECT * FROM TABLE1;
ELSE
SQL SELECT * FROM TABLE2;
LOAD TEMP INTO TABLE.qvd;
Please Guide me. Many Thanks for your help
Missing a 'Then' may be?
It should be like below. Remove Parenthesis in your IF statement. Because, IF statement need two arguments
IF weekday(today())='Sat' THEN
SQL SELECT * FROM TABLE1;
ELSE
SQL SELECT * FROM TABLE2;
Try like this
loveisfail one small correction you should close the if condition
IF weekday(today())='Sat' THEN
SQL SELECT * FROM TABLE1;
ELSE
SQL SELECT * FROM TABLE2;
END IF
Noted !! But, I don't think whether we need close IF statement like you mentioned. Tested and done. This Statement required when we having the script after that Else statement.
Thanks for correct root