Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Seperating first name and last name

hey i am new to qlikview , now i have got a listbox of names like

navneet kaushal

P.K jaiswal

S.P singh

balraj ahlawat

nikita barodia

now i want to seperate first name AND last name and only want to show first name but when it is p.k jaiswal or s.p singh it should show the full name ,can someone tell me any expression to do this?

and if it is possible through any expression please tell me how it is done?

8 Replies
whiteline
Master II
Master II

Hi.

There some useful string functions in QV:

=if(SubStringCount(Names, '.')>0, Names, SubField(Names, ' ', 1))

lironbaram
Partner - Master III
Partner - Master III

you can try something like

if(index(FullName,'.')>0,Name , left(FullName,index(FullName,'.')-1) AS FirstName

tresesco
MVP
MVP

like:

=If(Index(Name,'.'), Name, SubField(Name,' ',1))

Not applicable
Author

Like this

 

L:

Load * Inline [
AA
P.K jaiswal
S.P singh
balraj ahlawat
nikita barodia
]
;

Res:
Load *,
IF(SubStringCount(AA,'.')=0,SubField(AA,' ',1),AA) as AAA
Resident L;
Drop Table L;

Hope this helps you..!

nizamsha
Specialist II
Specialist II

TableA:

LOAD * Inline [

name

navneet kaushal

P.K jaiswal

S.P singh

balraj ahlawat

nikita barodia

];

LOAD SubField(name,' ',-1)as LName,

SubField(name,' ',1)as FName

  Resident TableA;

PradeepReddy
Specialist II
Specialist II

Try this..

Subfield(Name,' ',1) as First Name, // gives the first part of the name  

Subfield(Name,' ',2) as Last Name, // gives the second part of the name

Ex:

Subfield('Qlik Community',' ',1)  ---> Qlik

Subfield('Qlik Community',' ',2)  ---> Community

Thanks,

Pradeep

Anonymous
Not applicable
Author

Hi,check this..

HTH,

Ravi N.

preminqlik
Specialist II
Specialist II

Hi  there , try this

Load *,

if(len(trim(keepchar(Names,'.'))>0,Names,subfield(Names,' ',1))               as               FirstName

subfield(Names,' ',2)              as               LastName

from TABLE;