Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements

Breathe easy -- you now have more time to plan your next steps with Qlik!
QlikView 11.2 Extended Support is now valid through December 31, 2020. Click here for more information.

inowinowski
New Contributor

String function in Script

Hello,

I want to apply a string function to the field [DM Name] to extract initials. For example, if the name is John Smith, I want JS.

I have the following string function but how do I use this to create a new field with initials?

left([DM Name], 1)

&

left(subfield([DM Name], ' ', 2), 1)

Thanks,

Isabel

3 Replies
giakoum
Honored Contributor II

Re: String function in Script

load

....

,left([DM Name], 1) & left(subfield([DM Name], ' ', 2), 1) as [NewFieldName]

.....

from

jerem1234
Valued Contributor II

Re: String function in Script

Use it in script like:

Table1:

Load

[DM Name],

left([DM Name], 1) & left(subfield([DM Name], ' ', 2), 1) as [DM Name Initial],

....

FROM ....;


Hope this helps!

Re: String function in Script

Hi,

maybe a more generic approach in case there are also middle names:

LOAD [DM Name],

     Concat(Left(Names,1),'',RecNo()) as Initials

Group By [DM Name], RecNo;

LOAD [DM Name],

     SubField([DM Name], ' ') as Names,

     RecNo() as RecNo

Inline [

DM Name

John Smith

Jane Smith

Jane Smith

Bob Smith

John William Smith

Jane Mary Smith

];

QlikCommunity_Thread_129543_Pic1.png

hope this helps

regards

Marco