Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Split fullname to LastName, FirstName, and MI

Hi,

We have a FullName field with LastName,FirstName Middlename format. I need to split lastname, firstname, and MI to separate columns. Could someone please help? I need to do it through the expression and not the script itself. Right now, I was able to get LastName using SubField(Name,',',1)

Current FullName format:

FullName Format
Smith,James R
Smith,James Randy
Smith,James Randy JR

I need it to separate it like below:

LastNameFirstNameMI
SmithJamesR
SmithJamesR
SmithJamesR

Thank you.

1 Solution

Accepted Solutions
Peter_Cammaert
Partner - Champion III
Partner - Champion III

For FirstName you can use

Subfield(Subfield(Name, ',', 2), ' ', 1)

And for MI (which I assume contains only the initial character):

Left(Subfield(Subfield(Name, ',', 2), ' ', 2), 1)


The operations are self-explaining. If not sure about what is happening here, ask away.


[Edit] Right, it's MiddleInitial not MiddleName.

View solution in original post

4 Replies
Peter_Cammaert
Partner - Champion III
Partner - Champion III

For FirstName you can use

Subfield(Subfield(Name, ',', 2), ' ', 1)

And for MI (which I assume contains only the initial character):

Left(Subfield(Subfield(Name, ',', 2), ' ', 2), 1)


The operations are self-explaining. If not sure about what is happening here, ask away.


[Edit] Right, it's MiddleInitial not MiddleName.

Anonymous
Not applicable
Author

Thank you so much. That worked like a charm.

MarcoWedel

Hi,

depending on how reliable spaces occur in your data, one solution might be also:

QlikCommunity_Thread_272390_Pic1.JPG

LOAD [FullName Format],

    SubField([FullName Format],',',1) as LastName,

    TextBetween([FullName Format],',',' ') as FirstName,

    Mid([FullName Format],Index([FullName Format],' ')+1,1) as MI

FROM [https://community.qlik.com/thread/272390] (html, codepage is 1252, embedded labels, table is @1);

hope this helps

regards

Marco

Anonymous
Not applicable
Author

Wow! Thank you.