Qlik Community

New to Qlik Sense

If you’re new to Qlik Sense, start with this Discussion Board and get up-to-speed quickly.

Announcements
Tell us which business and trade publications you read most regularly: RESPOND NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
tommyl
Creator
Creator

Conditional load with exit script statement

Hello,

I have a table(switch) with single column(status) and it has value either 'true' or 'false'. 

I want my script to loaded if the value is only 'true' and to be not loaded if the value is 'false'. 

I wrote this in the editor:

LOAD status;

[switch]:
SELECT status
FROM [schema].[switch];

let vButton = fieldvalue(status, 1) ;
if (vButton='true') then

 

------ Load scripts-------

else
EXIT Script;
End If;

But this does not work. Anytime i load, it automatically exits script. 

Could you please help me on this issue?

Regards,

Tommy,

13 Replies
tommyl
Creator
Creator
Author

Yes:)

Kushal_Chawda

There are two things

1) Fieldvalue function always  takes fieldname parameter with single quotes. Hence below is the one change require

fieldvalue('status', 1)

2) Ideally vButton= 'true' condition should work but wrapping variable within single quotes using $ expansion always works when comparing texts. So for safer side you can always use variable like '$(vButton)' when you need to compare texts. If you want to compare numeric then no need to use single quotes, you can refer the variable  like $(vButton)

Hope this is helpful

tommyl
Creator
Creator
Author

Pretty helps, thank you.

Regards,

kdmarkee
Specialist
Specialist

This was exactly what I needed to solve a problem I had trying to get my script to load conditionally, thanks.  Side note, this worked in QlikView also.