Skip to main content
Announcements
Qlik Connect 2025: 3 days of full immersion in data, analytics, and AI. May 13-15 | Orlando, FL: Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

if statement question

This is seemingly simple but is causing me headache:

I have a variable which can be empty or have a value, i.e.

set myvar = ;

or

set marvar = 1;

I'm assuming that elsewhere I can test

if '$(myvar)' then or if isnull('$(myvar)') then

but this isn't working. I've tried many ways but didn't find a solution. I get an error message "script line error if ... then". $(#myvar) crashes script without any error.

On top of that putting msgbox('$(ScriptErrorDetails)') doesn't work, MsgBox isn't recoginzed in the script.

I have a feeling that I'm missing something very basic. Any thoughts?

2 Replies
amars
Specialist
Specialist

Try

if Trim('$(myvar)') = '' or isnull('$(myvar)') then

prieper
Master II
Master II

Normally you do not need the apostrophs, they are only needed when explicitly you need to declare a string. Within the normal statements in the script you also do not need to use the $(...), just the name should do it. Thus your statement should read

IF myvar = 1 THEN ... ELSE ... END IF


n.b.: If you can avoid it, would not have a variable containing NULL-value. It is better to have it reading either 0 or 1.

HTH
Peter