Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements
QlikView Fans! We’d love to hear from you.
Share your QlikView feedback with the product team… Click here to participate in our 5-minute survey.
Rules, plus terms and conditions, can be found here.
Not applicable

Check if field is null in script, in conditional statement

Hello,

I want to check if a value is Null, and if it is Null, I want to assign a value. This is what im trying:

if(IsNull([Stock]), [Stock] = 1, [Stock]) as [Stock]

Problem is, when I check the value the [Stock] = 0. So instead of making it 1 its 0.

How can I do this different?

Tags (3)
1 Solution

Accepted Solutions
Not applicable

Re: Check if field is null in script, in conditional statement

if([Stock]=' ',  1, [Stock]) as [Stock]

5 Replies
Sokkorn
Honored Contributor

Re: Check if field is null in script, in conditional statement

Hi,

Did you try something like this yet:

If(IsNull([Stock]),0,[Stock])     AS [Stock],

Or If(Len([Stock])=0,0,[Stock])     AS [Stock],

Regards,

Sokkorn

Not applicable

Re: Check if field is null in script, in conditional statement

All the non-null values turn into -1 for some reason when I use this.

Sokkorn
Honored Contributor

Re: Check if field is null in script, in conditional statement

Hi,

Does your [Stock] field have null value or not? And if [Stock] is null then what value you want to assign?

Regards,

Sokkorn

Not applicable

Re: Check if field is null in script, in conditional statement

if([Stock]=' ',  1, [Stock]) as [Stock]

Not applicable

Re: Check if field is null in script, in conditional statement

Thanks alot! this worked for me. But instead of [Stock]=' ' I could use IsNull([Stock]). But just putting 1 in the second field worked.

Community Browser