Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

kschramm
New Contributor II

Setting a default value on a column within a load statement

Hi.  I want to be able to set a default to the "Partner" column if it is null in the attributes QVD.  How is that accomplished within the load statements?  If it's blank or null, I want to populate it with "Other".  Thank you in advance. 

Left Join

LOAD
HPROP  as HMY,
SUBGROUP9  as Partner
FROM   $(vPathQVD)Attributes.qvd (qvd);

1 Solution

Accepted Solutions

Re: Setting a default value on a column within a load statement

May be this:


Left Join (TableName)
LOAD
HPROP  as HMY,
If(Len(Trim(SUBGROUP9)) = 0, 'Other', SUBGROUP9)  as Partner
FROM  $(vPathQVD)Attributes.qvd (qvd
);

3 Replies
Highlighted
brenner_martina
Valued Contributor II

Re: Setting a default value on a column within a load statement

Hallo Kurt,

you can use the following Statement:

Left Join
LOAD
HPROP  as HMY,
If(SUBGROUP9=' ' Or IsNull(SUBGROUP9 ), 'Other', SUBGROUP9)  as Partner
FROM   $(vPathQVD)Attributes.qvd (qvd);

Greetings from Martina Brenner

EVACO GmbH, Munich

Re: Setting a default value on a column within a load statement

May be this:


Left Join (TableName)
LOAD
HPROP  as HMY,
If(Len(Trim(SUBGROUP9)) = 0, 'Other', SUBGROUP9)  as Partner
FROM  $(vPathQVD)Attributes.qvd (qvd
);

MVP
MVP

Re: Setting a default value on a column within a load statement

Since you want to a column 'Partner' to another table, I would suggest not to use LEFT JOIN, but a MAPPING solution (with the benefit to easily define a default value), this will even work if the record in the Attributes.qvd is completely missing.

MAP:

MAPPING

LOAD HPROP,

          SUBGROUP9

FROM $(vPathQVD)Attributes.qvd (qvd)

WHERE len(trim(SUBGROUP9));

YourTable:

LOAD HMY,

          //All other fields from your original table

          ApplyMap('MAP', HMY, 'Other') as Partner

FROM ...;

Community Browser