Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
maarcus_smith
Contributor II
Contributor II

IF STATEMENT HELP

hi,

i have an if statement that i use whereby it will fail the app on purpose if the max date is <= the time of a different qlik app.

however, for some reason the app is not failing and i cant understand why.

my if statement: 

//if max date of source files is less than the date of report late reload – 10 minutes then no need to reload the qlikview report
if maxdate<= num($v_NUM_File_Date-10/1440) then 
drop table Nonexistabtable;
end if
//dropping a table which does not exist causes the qlikview report to error

and when i put the maxdate and $v_NUM_File_Date in a text object i get the following:

maarcus_smith_0-1638977764267.png

 

surely based off the above this app should fail? however it is not its running fine.

 

any ideas?

thanks

 

Labels (2)
1 Solution

Accepted Solutions
Or
MVP
MVP

MaxDate could be a field rather than a variable, in which case you could use it in the front-end but not in the control statement. Why are you using MaxDate when you appear to already have a vMaxDate set?

 

View solution in original post

4 Replies
Or
MVP
MVP

Run your app in debug mode, step by step, and you should be able to see the flow and the variable values and figure out what it's doing. One thing I'd look at is to keep the types consistent, so if you're going to num() one, you should num() the other, but that might not be related at all, just good practice in general.

maarcus_smith
Contributor II
Contributor II
Author

hi @Or , yes i have them kept at num in my script and have gone through debug mode, it appears that it just skips the "drop table Nonexistabtable" completely 

 

i went to debug and it looks like it has a null for the maxdate? am i reading it correctly? is that why my if statement is not working?

how could it be null in the if statement but once the app opens, there is a maxdate in there?

maarcus_smith_0-1638979953747.png

 

Or
MVP
MVP

MaxDate could be a field rather than a variable, in which case you could use it in the front-end but not in the control statement. Why are you using MaxDate when you appear to already have a vMaxDate set?

 

maarcus_smith
Contributor II
Contributor II
Author

i was using a field as i was concatenating two different max dates together. however as you suggested, i just made it a variable using  let vMaxDate2 = peek('maxdate') and it worked!

thanks so much for your help i didnt know you couldn't use a field in control statement in script!