Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
naveenchellaara
Contributor III
Contributor III

Checking for NULL in script

How to check for null values in the script file?

I have a variable.

var1

I need to check whether the value of the variable is null or not.

i tried

IF( $(var1) = Null

then

set Var2 = Blue();

endif

but it is thowing an error.

Regards

Naveenchellaaraam

1 Solution

Accepted Solutions
rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

I think the most robust test is

len('$(v1)') = 0

Note the single quotes around the variable.

-Rob

http://robwunderlich.com

View solution in original post

4 Replies
nagaiank
Specialist III
Specialist III

IsNull(X) returns True if X is null.

Also Len(Trim(X)) = 0 if X is null.

http://community.qlik.com/docs/DOC-3155 has more details.

SunilChauhan
Champion
Champion

try below code .

if(isnull($(var1)),Blue())

or

if(len($(var1))=0,Blue())

or

if(($(var1))=' ',Blue())

hope this helps

Sunil Chauhan
phaneendra_kunc
Partner - Specialist III
Partner - Specialist III

Try this....

If Len ($(var1)) = 0 then

Set Var2 = 'blue()';

Endif.

rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

I think the most robust test is

len('$(v1)') = 0

Note the single quotes around the variable.

-Rob

http://robwunderlich.com