Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Discover how organizations are unlocking new revenue streams: Watch here
cancel
Showing results for 
Search instead for 
Did you mean: 
harleen_singh
Creator III
Creator III

How to check null value?

hello,

I am checking the null value in variable Filter like this.

               Let Filter=trim(peek('Filter',$(i),'TableNames'));

IF not IsNull($(Filter)) THEN

//code

ELSE

//code

ENDIF

I want to check if Filter gets null then code after ELSE should go

and if Filter gets some string the code after IF should go??

is it correct??

when i get string value in filter varialbe it shows errror

thanks

Lavi

8 Replies
Not applicable

The code seems to be correct.

Which error do you get ?

SunilChauhan
Champion II
Champion II

may be in place of let you need to write set

because if you create varible using set then it is calculated uing $ sign expression

and let will calculate directly

other wise code looks good

hope this helps

Sunil Chauhan
harleen_singh
Creator III
Creator III
Author

@sunil,

            Can u see i have used Peek function which doesn't work when i use set

thanks

harleen_singh
Creator III
Creator III
Author

Philippe Motillon

This is the error i am getting

Script line error:

IF not IsNull(De Kil Kraanbedrijf) THEN

see when the string value comes in the Filter variable it gives error. But when null comes in it is okay.

thanks

SunilChauhan
Champion II
Champion II

but it iwll get calculated when you use

$(Filter)

please try once and then let me know

Sunil Chauhan
SunilChauhan
Champion II
Champion II

            Let Filter=trim(peek('Filter',$(i),'TableNames'));

IF not IsNull($(Filter)) THEN

//code

ELSE

//code

ENDIF

you need to define $(i) also

Sunil Chauhan
jonathandienst
Partner - Champion III
Partner - Champion III

Lavi

I think the problem is the $ expansion of Filter inside the IsNull() function. This cause the 'evaluated' value of Filter to be passed to IsNull, which is probably invalid and therefore causing your error.

Instead of IsNull($(Filter)), use

Let Filter = ....

If Not(IsNull(Filter)) Then

Else

End If

Regards

Jonathan

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
sridhar240784
Creator III
Creator III

Hi,

You may need to add single qoute around the '$(Filter)' variable when you check not isnull since you are using LET variable.

When you use the LET varibale, your expression is already calculated and your variable will have the resultant value. If you again equate the 'Filter' variable with variable expansion $(Filter) when your variable is holding null value then you`ll get script line error.

Have a look at the attached application.

Let Filter=trim(peek('Filter',$(i),'TableNames'));

IF not IsNull($(Filter)) THEN

//code

ELSE

//code

ENDIF

Hope this helps you.

-Sridhar