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 Name | Last Name | Preferred Name |
Johnathon | Smith | John |
Steve | Waugh | |
Andrew | Flintoff | Andy |
.
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
Solved! Go to Solution.
Hi @mustufa2019
No need for Left
If IsNull([Preferred First Name]) Then
[First Name]+[Last Name]
Else
[Preferred First Name] + [Last Name]
Endif
Cheers,
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
@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?
If IsNull([Preferred First Name]) Then
""
Else
[Preferred First Name] + [Last Name]
Endif
double " without space in the middle represents for empty.
@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