We are celebrating the 10-year anniversary of the Alteryx Community! Learn more and join in on the fun here.
Start Free Trial

Alteryx Designer Desktop Discussions

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

IF Statement in Formula Tool not showing the desired output

willd9
7 - Meteor

I have a column called source_title and I'm trying to run a simple IF statement on it to give a new value to empty fields. So the logic is, if the field is empty or "(blank)" then replace that field with "Unknown". My code is below:

 

if IsEmpty([Source_Title]) or [Source_Title] = "(blank)" then [Source_Title] = "Unknown" else [Source_Title] endif

 

The code outputs a 0 instead of "Unknown" for all of the empty fields, does anyone know why? The format of the field is V_String.

2 REPLIES 2
DataNath
17 - Castor
17 - Castor

Hey @willd9, I recently wrote a blog on common Formula errors, one of which is this exact scenario! See section 4 here: https://community.alteryx.com/t5/Engine-Works/Troubleshooting-Common-Formula-Expression-Errors/ba-p/...

 

Essentially, you'll just want to remove the [Source_Title] = from your current expression so it should be:

 

if IsEmpty([Source_Title]) or [Source_Title] = "(blank)" then "Unknown" else [Source_Title] endif
binuacs
21 - Polaris

@willd9 Another way of using this formula with the Trim function 

 

IIF(IsEmpty(Trim([Source_Title])),’unknown’,[Source_Title])

Labels
Top Solution Authors