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

"null" value to "1"

Hi all,

I have SQL table, how to set up , if the value is " null " written 1. Using my script i'm i get value "-"

/Sample/

[products]:

LOAD ID as [item.ID],

    Name as [pr.name],

    Code as [pr.code],

    TareWeight as [pr.twt],

    if ((TareWeight='Null') or (TareWeight=0),1,TareWeight) as [Weight]

    ;

SQL SELECT *

FROM postgres."public".erpoitm

Tags (2)
1 Solution

Accepted Solutions
marcarreras
Valued Contributor

Re: "null" value to "1"

try this:

[products]:

LOAD ID as [item.ID],

    Name as [pr.name],

    Code as [pr.code],

    TareWeight as [pr.twt],

    if(len(TareWeight)>0, TareWeight, 0) as [Weight]

    ;

SQL SELECT *

FROM postgres."public".erpoitm

Marc.

6 Replies
Not applicable

Re: "null" value to "1"

Hi,

you can write in SQL itself.

Select isnull(TareWeight,1) as TareWeight from postgres."public".erpoitm.

Not applicable

Re: "null" value to "1"

Hi,

LOAD ID as [item.ID],

  Name as [pr.name],

    Code as [pr.code],

    TareWeight as [pr.twt],

alt(TareWeight,1) as [Weight],

if(isnull(TareWeight),1,TareWeight) as [Weight_NEW]

     ;

SQL SELECT *

FROM postgres."public".erpoitm

Re: "null" value to "1"

Alt(TareWeight,1) as [Weight]

marcarreras
Valued Contributor

Re: "null" value to "1"

try this:

[products]:

LOAD ID as [item.ID],

    Name as [pr.name],

    Code as [pr.code],

    TareWeight as [pr.twt],

    if(len(TareWeight)>0, TareWeight, 0) as [Weight]

    ;

SQL SELECT *

FROM postgres."public".erpoitm

Marc.

Not applicable

Re: "null" value to "1"

Thanks all for yours answers, resolved

markodonovan
Valued Contributor

Re: "null" value to "1"

Hi Aurimas,

You could also use the following

NullAsValue TareWeight;

SET NullValue = 1;

Thanks

Mark

https://www.techstuffy.com/course/practical-qlikview-qlikview-beginners/

Community Browser