Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
robin_heijt
Creator
Creator

If Null then

Hi,

The following code is linked through different files with the key of "ID"

Load*,

    If("Macro Entity Description3" ='SOUTH EUROPE', 'BU South',

    If("Macro Entity Description3" ='WEST EUROPE', 'BU West',

    If("Macro Entity Description3" ='NORTH EUROPE', 'BU North',

    If("Macro Entity Description3" ='EAST EUROPE', 'BU East',

    If("Macro Entity Description3"=Null(),'Zone','N/A'))))))))) as BU;

I am trying to achieve the following:

At the end of this IF Statement it should see if a value is blank then it should return 'Zone', however if there is no link present it should return N/A.

Right now it is returning everyone that has a blank or no connection as N/A.

What am I doing wrong?

4 Replies
vamsee
Specialist
Specialist

Instead of

          If("Macro Entity Description3"=Null()

Try Isnull() or Len(Trim("Macro Entity Description3"))<0 or "Macro Entity Description3"='' or "Macro Entity Description3"=' '

robin_heijt
Creator
Creator
Author

Unfortunately none worked. Thank you anyway.

vamsee
Specialist
Specialist

Try NullAsValue for the column and see.. like

NullAsValue [Macro Entity Description];

SET NullValue ='Value Not Found';

LOAD *

if.... If( Macro Entity Description ='Value Not Found', 'Zone'

maxgro
MVP
MVP

// test data

T:

load if([Macro Entity Description3]='null', null(), [Macro Entity Description3]) as [Macro Entity Description3] inline [

Macro Entity Description3

SOUTH EUROPE

NORTH EUROPE

WEST EUROPE

EAST EUROPE

null

other

];

T2:

Load

     *,  

     IF(len(trim("Macro Entity Description3"))=0,

          'Zone',

          PICK(WILDMATCH([Macro Entity Description3],

                 'SOUTH EUROPE', 'WEST EUROPE', 'NORTH EUROPE', 'EAST EUROPE', '*'),

                 'BU South',  'BU West', 'BU North', 'BU East', 'N/A'

            ))

  as BU

RESIDENT T;

DROP TABLE T; 

1.png