Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements
Make your voice heard! Participate in the 2020 Wisdom of Crowds® Survey. BEGIN SURVEY
Highlighted
naveenchellaara
New 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

Tags (1)
1 Solution

Accepted Solutions
Highlighted
MVP & Luminary
MVP & Luminary

Re: Checking for NULL in script

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
Highlighted
nagaiank
Valued Contributor III

Re: Checking for NULL in script

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.

Highlighted
SunilChauhan
Esteemed Contributor

Re: Checking for NULL in script

try below code .

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

or

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

or

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

hope this helps

Highlighted
Partner
Partner

Re: Checking for NULL in script

Try this....

If Len ($(var1)) = 0 then

Set Var2 = 'blue()';

Endif.

Highlighted
MVP & Luminary
MVP & Luminary

Re: Checking for NULL in script

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