2nd Occurrence of a character in a string
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
I am new to Alteryx,
I am having below data of Names, I want to segregate Names column into "First name", Middle name", "Last Name".
As per my logic, I am trying to use LEFT() and RIGHT() functions and wanted to find out second position/occurrence of character space, Can anyone let me know, how to find second occurrence of character in a string?
Names
Nilesh Dilip Haval
Akshay Dilip Haval
S P Balasubramaniyam
P K Jain
Naval Kumar Singh
Rahul Anand Patel
Viyalakshmi Raman Mahadevkar
Lakshmianand George Fernandes
Solved! Go to Solution.
- Labels:
- Custom Tools
- Parse
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Hi @Vaish369 ,
you can find the 2nd occurence of a character using the formula
FindString(SubString([Names], FindString([Names], ' ') + 1), ' ')
The "inner" FindString finds the first occurence, using Substring you "cut off" the first part of the string starting at the first character after the space, the "outer" FindString find the second space. You can calculate the starting position of the last name as:
Character position of 1st space + 1 ( = first character after first space) + Character position of space in the remaining part + 1 (= first character after first space):
FindString([Names], ' ') + 1 + FindString(SubString([Names], FindString([Names], ' ') + 1), ' ') + 1
Btw: If you want to split the name in First Name, Middle Initial and Last Name, you could also eg. replace the spaces by "|" and use a Text To Columns tool.
Let me know if it works for you.
Best,
Roland
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
@RolandSchubert
Thank you for your reply,
Actually, I am trying different approaches to achieve this,
Other approach I tried is by using GETWORD() function and passing indexes as 0, 1, 2 to return first name, second name and last name..
