Qlik Community

New to QlikView

Discussion board where members can get started with QlikView.

Announcements

Breathe easy -- you now have more time to plan your next steps with Qlik!
QlikView 11.2 Extended Support is now valid through December 31, 2020. Click here for more information.

nickjose7
Contributor

How to create IF statement to make field from another field.

kush141087its.anandrjsantoniotimanloveisfail serj_shu

Hi,

I have the following data:

SKU CodeCategory
001AA
002BB
003CC
004DD
005EE
006FF

Now I want to create a field say "Channel" with values 'X4' and 'X6' like this:


Load

SKU Code,

If(Wildmatch (Category,'AA', 'BB', 'CC','DD'),'X4',

If(Wildmatch (Category,'AA', 'BB', 'CC','DD','EE','FF'),'X6')) as Channel


But this is not working. It is giving correct value of X4 but in case of X6 it is only considering values which are not covered in X4 i.e EE & FF only.


Please help.


Note: I cannot take two loads as it will multiple my data which happens to be SKU wise volume which I have to later show in a straight table where Category and Channel both will be dimensions. Basically the need for channel is to show sub totals on the basis of X4 & X6.

Thanks

Nick

1 Solution

Accepted Solutions

Re: How to create IF statement to make field from another field.

try like below

Data:

LOAD * Inline [

SKU ,Category

001 ,AA

002 ,BB

003 ,CC

004 ,DD

005 ,EE

006 ,FF

];

Link:

load distinct Category,

        'X4' as Channel

resident Data

where match (Category,'AA', 'BB', 'CC','DD');


Concatenate(Link)

load distinct Category,

        'X6' as Channel

resident Data

where match (Category,'AA', 'BB', 'CC','DD','EE','FF');

5 Replies
Chanty4u
Esteemed Contributor III

Re: How to create IF statement to make field from another field.

what is the result you want to see?

Chanty4u
Esteemed Contributor III

Re: How to create IF statement to make field from another field.

May be try this

a:

load *,

if(match(Code,'AA','BB','CC','DD'),'x4',null()) as new ,

if(match(Code,'AA','BB','CC','DD','EE','FF'),'x6',null()) as new1;

LOAD * Inline [

SKU ,Code

001 ,AA

002 ,BB

003 ,CC

004 ,DD

005 ,EE

006 ,FF

];

exit SCRIPT;

nickjose7
Contributor

Re: How to create IF statement to make field from another field.

I want to see something like below:

Let our data be:

SKUCategoryVolume
001AA10
002BB20
003CC30
004DD40
005EE50
006FF60

Then the result should be like:

 

ChannelVolume
X4100
X6210

Re: How to create IF statement to make field from another field.

try like below

Data:

LOAD * Inline [

SKU ,Category

001 ,AA

002 ,BB

003 ,CC

004 ,DD

005 ,EE

006 ,FF

];

Link:

load distinct Category,

        'X4' as Channel

resident Data

where match (Category,'AA', 'BB', 'CC','DD');


Concatenate(Link)

load distinct Category,

        'X6' as Channel

resident Data

where match (Category,'AA', 'BB', 'CC','DD','EE','FF');

nickjose7
Contributor

Re: How to create IF statement to make field from another field.

Thanks Kushal. This works though I was looking for correction in the original IF statement if possible.

Community Browser