Get Inspire insights from former attendees in our AMA discussion thread on Inspire Buzz. ACEs and other community members are on call all week to answer!

Alteryx Designer Desktop Discussions

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

Running IF Statements

mustufa2019
8 - Asteroid

I am trying to create a unique ID by combining the Preferred Name and Last Name of users. In some cases, the there is no preferred name and i would like to use the first name in that case: see below example of input data and output expected

 

Input

First NameLast NamePreferred Name
JohnathonSmith

John

SteveWaugh 
AndrewFlintoffAndy
   

.

Output:

Unique ID

JohnSmith
SteveWaugh
AndyFlintoff

 

i tried using the below formula but its not letting it run

 

If IsNull([Preferred First Name]) Then
Left([First Name]+[Last Name]
Else
Left([Preferred First Name] + [Last Name]
Endif

 
 
6 REPLIES 6
Thableaus
17 - Castor
17 - Castor

Hi @mustufa2019 

 

No need for Left

 

If IsNull([Preferred First Name]) Then
[First Name]+[Last Name]
Else
[Preferred First Name] + [Last Name]
Endif

 

Cheers,

CharlieS
17 - Castor
17 - Castor

Agreed with @Thableaus.

 

Also, IsEmpty( would be a better test because it covers null and empty fields. I also added a couple RegEx_Replace( functions to remove space characters since.

 

If IsEmpty(REGEX_Replace([Preferred Name],"\s","")) Then
[First Name]+[Last Name]
Else
REGEX_Replace([Preferred Name]+[Last Name],"\s","")
Endif

mustufa2019
8 - Asteroid

@Thableaus  and @CharlieS thank you for the help! Worked perfectly! One additional questions, what if i would like to keep the rows empty if there is no Preferred name?

 

delilah
8 - Asteroid

If IsNull([Preferred First Name]) Then
""
Else
[Preferred First Name] + [Last Name]
Endif

 

double " without space in the middle represents for empty.

mustufa2019
8 - Asteroid

@delilah thank you but by running this script, the column will still populate with the last name. if there is not preferred name, i would like the row to be blank

 

 
delilah
8 - Asteroid

キャプチャ.JPG

if this is what you want, please see the attached workflow.

Labels