I am having an issue with a little script I'm writing.
I'm extracting data from database tables using SQL, and I would like to apply a condition to only 1 table from this list.
For some reason Qlikview does not like my else statement as that's where it's breaking.
I have not written an IF statement containing SQL before so it's a first for me.
Any help would be appreciated.
For i = 0 To $(vTableCount)
Let vCurrentTable = Peek('TableName', $(i), 'SQLTableList');
if $(vCurrentTable) = 'SAMPLE_RESULT' THEN
SQL SELECT * FROM [lvl].[dbo].$(vCurrentTable)
WHERE Date(EntryDt, 'DD/MM/YYY') >= '01/01/2010';
SQL SELECT * FROM [lvl].[dbo].$(vCurrentTable);
STORE $(vCurrentTable) into $(vDatasource)$(vCurrentTable).QVD(qvd);
DROP Table $(vCurrentTable);
You're missing an END command to that IF statement.
You could also just set a date variable to use in a single SQL code instead of writing the full code - this just seems a cleaner option. Just set the date in the where clause to something like'01/01/1900' to select everything and place that outside the IF..ELSE..END command.