Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

Referencing "NULL" in an if statement

DavidOliverChapman
7 - Meteor

Hello Community,

 

Another "If" question:

 

If have used "Find and Replace" to add a column to a dataset showing "C.London" (as in Central London" to my dataset. The dataset covers all geographies in EMEA.

 

The remaining cells show as [NULL].

 

I would like to fill the remaining cells with either "R.UK" or "Other".

 

I have tried a number of if/elseif statements, using "NULL" and NULL() but in each case they seem to fail.

 

The latest attempt - where I have tried to create in FORMULA a new column containing either "C.London", "Rest.UK" or "Other" is this:

 

IF [CentralLondon] = "C.London" THEN "C.London"
ELSEif [CentralLondon] = "NULL" && [Country_tx] = "United Kingdom " THEN "Rest.UK"
Else "Other"
ENDIF

 

If it helps, CentralLondon and Country_Tx are V_String...

 

Again, thanks for the help...

 

DoC

4 REPLIES 4
BenMoss
ACE Emeritus
ACE Emeritus

There are a couple of ways to do this @DavidOliverChapman 

 

ISNULL([Field])

 

or [Field] = NULL()

 

So your statement could be...

 

IF [CentralLondon] = "C.London" THEN "C.London"
ELSEif isnull([CentralLondon]) && [Country_tx] = "United Kingdom " THEN "Rest.UK"
Else "Other"
ENDIF

 

or

 

IF [CentralLondon] = "C.London" THEN "C.London"
ELSEif [CentralLondon] = NULL() && [Country_tx] = "United Kingdom " THEN "Rest.UK"
Else "Other"
ENDIF

Thableaus
17 - Castor
17 - Castor

Hi @DavidOliverChapman 

 

You should use IsNull(Field) function.

 

IF [CentralLondon] = "C.London" THEN "C.London"
ELSEIF IsNull( [CentralLondon]) && [Country_tx] = "United Kingdom " THEN "Rest.UK"
Else "Other"
ENDIF

 

Cheers,

Kenda
16 - Nebula
16 - Nebula

Hi @DavidOliverChapman 

 

You're close! In your else statement, just change it to say isnull([FieldName]) instead of checking with the equals sign. This should help!

DavidOliverChapman
7 - Meteor

@BarnesK @BenMoss @Thableaus

 

Thanks for your help on this - absolutely brilliant. 

 

DoC

Labels