Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi
The requirement I have is to load the part of the script on condition. If status = In Progress, then the further script should not load, else the further script shall execute. The issue is even if the status is in progress, the exit script is not working and the load statement in else condition is getting execute. Please advise.
the below is my script -
----- OLE DB connection string ------
JobStatus:
select status from table1;
let vStatus = fieldvalue('status', 'In Progress') ;
If ('$(vStatus)' = 'In Progress') then
Exit Script;
else
-----LOAD statements ----
End IF;
Fieldvalue() isn't correct applied because it expects the fieldvalue-index as second parameter and therefore your variable-assignment should be look like:
let vStatus = fieldvalue('status', 1);
... assuming that there is really just one record.
- Marcus
yes, the field Status is having just one record in QV.
Have changed the filedvalue parameter, as suggested. However, it's still not working. Still, even though the status is 'In Progress', the load statement after exit script is getting load. Any help would be really appreciable. Thanks.
Something like this @sk88024 ?
JobStatus:
//select status from table1;
load
'In Progress' as status
autogenerate(1);
let vStatus = peek('status', 0, 'JobStatus') ;
If ('$(vStatus)' = 'In Progress') then
Exit Script;
else
load
'In Progress 2' as status2
autogenerate(1);
End IF;
drop table JobStatus;
exit script;
You need to check the value, for example with:
let vStatus = text(fieldvalue('status', 1));
TRACE '$(vStatus)';
because Qlik is case-sensitive and each difference to your comparing-value will lead to a mismatch. There could be also any other chars like additionally spaces or similar. Thinkable is also that your value isn't a string (you may see one if you look within your database) else a numeric value. Text() is added to display a visible value because fieldvalue() hasn't a string-representation and looking on it returns usually just ? as a replacement - but it's not the stored value.
Regarding to the above you may need some adjustments to your comparing-value and/or transforming the database-value with functions like: trim(), keepchar(), replace(), upper() or similar.
Beside this fieldvalue() accessed the field and not your loaded table. If you has anywhere before loaded a field status you couldn't access a certain value anymore - in this case you need to change the approach to peek() like demonstrated from QFabian.
- Marcus