Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
pkelly
Specialist
Specialist

Split Name Field

Hi...

I am importing from a csv file which has a user name column...

The data in this field is PaulKelly(6653) , Joe Bloggs(6621)...

I want to get the user name out and split into first name / last name...

e.g. PaulKelly(6653) would become Paul / Kelly

Any ides?

Thanks

Paul

1 Solution

Accepted Solutions
petter
Partner - Champion III
Partner - Champion III

You can actually do it like this with Regular Expressions by using a function written in VBScript and call it from the load script as a normal function. The VBScript function has to be put in the Tools / Module. I have attached the sample app that these screenshots are taken from. Even though the Load Script language have no Regular Expression functions you can use the RegEx support in VBScript.

2016-02-12 #2.PNG

2016-02-12 #1.PNG

The RegEx VBScript functions are from the QlikFix blog of BarryHarmsen and copied from his example application that you can find there. Search for Regular Expressions in QlikView on his blog.

View solution in original post

17 Replies
sunny_talwar

If the first name first letter and last name first letter are the only two things which will be capitalized then you can probably try using a combination of PurgeChar(), Left(), SubField functions.

kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi Paul,

Everything is possible when you have proper logic in place.

In your case you need to let us know on what basis you will split the characters?

Do you have the space in between two words or is there any other logic?

Regards,

Kaushik Solanki

Please remember to hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!
pkelly
Specialist
Specialist
Author

Hi...

The data is stored as, for example, PaulKelly(6653)

I want to split..

Paul into First Name

Kelly into Last Name

MayilVahanan

Hi Paul,

If the space is available between first name and last name means, try like this

LOAD SubField(Name,' ',1) AS FirstName, Left(SubField(Name,' ', 2), FindOneOf(SubField(Name,' ', 2),'(')-1) AS LastName Inline

[

Name

Joe Bloggs(6621)

];

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.
sunny_talwar

May be this:

=SubField('PaulKelly(6653)', Right(KeepChar('PaulKelly(6653)', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'), 1), 1) & ' / ' &

Right(KeepChar('PaulKelly(6653)', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'), 1) &

SubField(SubField('PaulKelly(6653)', Right(KeepChar('PaulKelly(6653)', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'), 1), 2), '(', 1)

sunny_talwar

Try something like this:

SubField('PaulKelly(6653)', Right(KeepChar('PaulKelly(6653)', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'), 1), 1) as FirstName,



Right(KeepChar('PaulKelly(6653)', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'), 1) &

SubField(SubField('PaulKelly(6653)', Right(KeepChar('PaulKelly(6653)', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'), 1), 2), '(', 1) as LastName

Replace PaulKelly(6653) with your field name above

awhitfield
Partner - Champion
Partner - Champion

HI Paul,

not sure you can do this if there's no space between first and last name.

Andy

kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

Dear Paul,

I guess i couldn't make you understand what I wanted to say.

Now in your example which you gave.

PaulKelly(6653)

Joe Bloggs(6621)

If you see both words, in first word, First 4 characters are first name and remaining as Last name, but in Second example only 3 characters are first name and remaining all are Last Name.

So do you think that in all such word first 4 characters will be First Name?

If yes then it is easy, we can split using the functions which Sunny said.

Regards,

Kaushik Solanki

Please remember to hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!
pkelly
Specialist
Specialist
Author

Apologies, there is no space between the names - typo in my original text.