Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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
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.
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.
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.
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
Hi...
The data is stored as, for example, PaulKelly(6653)
I want to split..
Paul into First Name
Kelly into Last Name
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)
];
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)
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
HI Paul,
not sure you can do this if there's no space between first and last name.
Andy
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
Apologies, there is no space between the names - typo in my original text.