Jan 18, 2023 08:01 AM
Hello!
I know at one time there were several threads that spoke to extracting the First Name from a full name, and also a formula for extracting the Last Name. While I can find several threads with the code for First Name, I cannot find any that show for Last Name now that I'm in need of it 😂
First Name Formula Found:
IF(FIND(" ",{Full Name})=0, {Full Name}, LEFT({Full Name}, FIND(" ",{Full Name})-1))
I've tried different variations using RIGHT instead of left, but I either get really odd returns where some last names are extracted properly, and others are completely way off, or I get blank returns.
I have several Full Names that include more than 1 name as that Last Name. Example: Olivia Gutierrez Lawson. I would need "Gutierrez Lawson" to appear in the last name field with the formula.
I feel confident in some of my formula creation skills and then there are times like this when I realize just how little I know haha. I am so grateful there is a community of people who are way better at understanding formulas than I am that I can ask for help from.
Solved! Go to Solution.
Jan 19, 2023 02:48 AM - edited Jan 19, 2023 02:55 AM
try this:
First name: REGEX_EXTRACT(Name, "^[^ ]+")
Last name: REPLACE(Name, 1, LEN({First name}) + 1, "")
Jan 18, 2023 09:42 AM
One of the issues you'll run into with extraction is that there is no way to differentiate whether a space is in the first name ("Mary Ann") or the last name ("Gutierrez Lawson"). Is it possible to use separate fields for first and last names and then concatenate them when you need the full name?
Jan 18, 2023 10:57 AM
@Ron_Daniel that is the typical way I setup every table, however, someone set this one up and I'm trying to make it work without having to do a ton of manual work now afterwards 🙃
I'm willing to risk the first name being split up as I recognized that as a potential issue too.
Jan 18, 2023 11:18 AM
Ah, inheritance!
Well, it's less than ideal, but you can make it work (mostly) like this:
First Name formula is
Jan 19, 2023 02:48 AM - edited Jan 19, 2023 02:55 AM
try this:
First name: REGEX_EXTRACT(Name, "^[^ ]+")
Last name: REPLACE(Name, 1, LEN({First name}) + 1, "")
Jan 19, 2023 04:50 AM
@Steve_Haysom 's solution is shorter, more elegant, and produces better results. Win!
Jan 19, 2023 04:58 AM
thanks Ron! :@)
Jan 19, 2023 06:13 PM
@Steve_Haysom THANK YOU! That works like a dream and I would have NEVER come up with that myself.
Much appreciate to you as well, @Ron_Daniel!
Jan 20, 2023 05:52 AM
@Cole_Wedemeier - this has prompted me to finally focus on learning regular expressions (REGEX). They're super-powerful for all of us to have in our formula toolbox!