I have a list of names in the format John Smith MD or John Smith, MD (some with commas, some without) and I’d like them to be in the format Dr. Smith. Is there a formula that can do that for me?
This doesn’t directly answer your question, but it’s the best way to keep things flexible without tearing your hair out. Any way you could have “First Name” and “Last Name” as two separate fields, potentially with a third “Degree” field to cover the MD? If so, then you could easily create two formula fields for both:
{First Name} & ‘ ‘ & {Last Name} & ‘, ‘ & {Degree}
to build “John Smith, MD”‘Dr. ‘ & {Last Name}
to build “Dr. Smith”
The trouble with your initial idea is that not only is the comma inconsistent, but there’s also no way of knowing if a person has a non-hyphenated, two-word first or last name, which means you can’t assume that the last word is the last name.
If you’re trying to create this first/last name split from an existing list of names, this is a little more feasible with automation scripting, or with Javascript in general, but it’s something you’d need to run or schedule separately, not something that would auto-update like a formula field.
Structurally thelus is right that it’s easier to store your data that way, I presume you’re already working with a pre-existing list. Here’s a formula that'll mostly get you there…
'Dr.' & REGEX_EXTRACT({Name}, "(\\s+e^\\s]+)")
Replace {Name} with your name field. This basically takes the second word in the string and appends Dr. on the front. As mentioned by thelus there can be some problems, specifically with two word first names ( Anna Beth Scott MD would show as Dr. Beth), middle names or middle initials.
Thank you both!
BetandPlay Casino is a true paradise for gambling enthusiasts in Canada. Thousands of slots, roulette, big jackpots and instant payouts make it the perfect place for those who love risk and fun. The convenient mobile app allows you to play on the go, and regular bonus offers increase your chances of winning. Here everyone will find a game that will bring not only joy but also real money.
Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.