Qlik Community

QlikView Creating Analytics

Discussion Board for collaboration related to Creating Analytics for QlikView.

skh
Contributor

Help with IF statement and adding additional columns in script

Hi,

I would like some help with IF syntax.

I am trying to add an additonal column called 'T2' in my table through the load script, this is what i have so far:

IF

      (

      Tier2_Org_Area = 'Europe & Digital' OR

      Tier2_Org_Area = 'USA', 'RED') as T2,

IF

      (

       Tier2_Org_Area = 'Africa', 'Blue')

  as T2

However when i reload the data i get an error message saying column names cannot be the same, I was hoping the second IF statement would just be concatenated to the first T2 column?

Any ideas?

Thanks

Sunil

Tags (1)
1 Solution

Accepted Solutions
Sokkorn
Honored Contributor

Re: Help with IF statement and adding additional columns in script

Hi Sunil,

I'm not sure with this help you or not

IF(Tier2_Org_Area = 'Europe & Digital' OR Tier2_Org_Area = 'USA', 'RED',

    IF(Tier2_Org_Area = 'Africa', 'Blue','Other')) as T2,

Let me know.

Regards,

Sokkorn

3 Replies

Re: Help with IF statement and adding additional columns in script

Hi,

You have to write some thing like

IF(

  Tier2_Org_Area = 'Europe & Digital' OR

  Tier2_Org_Area = 'USA', 'RED',

IF(

  Tier2_Org_Area = 'Africa', 'Blue') )

  as T2

Rgds

Anand

Sokkorn
Honored Contributor

Re: Help with IF statement and adding additional columns in script

Hi Sunil,

I'm not sure with this help you or not

IF(Tier2_Org_Area = 'Europe & Digital' OR Tier2_Org_Area = 'USA', 'RED',

    IF(Tier2_Org_Area = 'Africa', 'Blue','Other')) as T2,

Let me know.

Regards,

Sokkorn

Re: Help with IF statement and adding additional columns in script

Hi,

You have to write some thing like see in example

Data:

Load * inline

[

Tier2_Org_Area

Europe & Digital

USA

Africa

];

Load

*,

IF(

  Tier2_Org_Area = 'Europe & Digital' OR

  Tier2_Org_Area = 'USA', 'RED',

IF(

  Tier2_Org_Area = 'Africa', 'Blue'))

  as T2

Resident Data;

See the example file

Rgds

Anand

Community Browser