Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

david_pearson
New Contributor III

Reorder text in a field

Hi 

 

looking for some help at displaying a field in a different order. im sure it will be a combination of left and right functions but cant work it out.

i have a field called MM_CURR_SERV_OWNER which shows the owners name as SMITH, PAUL

i want an expression that shows the MM_CURR_SERV_OWNER as PAUL SMITH or even better Paul Smith.

can you help please

thanks

2 Solutions

Accepted Solutions
Partner
Partner

Re: Reorder text in a field

In you load script add another column
Capitalize(
right(MM_CURR_SERV_OWNER,len(MM_CURR_SERV_OWNER)-Index( MM_CURR_SERV_OWNER, ',' )) & ' '& left(MM_CURR_SERV_OWNER,Index( MM_CURR_SERV_OWNER, ',' )-1)
) as MM_CURR_SERV_OWNER_FORMATTED

e.g.

Capitalize(
right('SMITH, PAUL',len('SMITH, PAUL')-Index( 'SMITH, PAUL', ',' )) & ' '& left('SMITH, PAUL',Index( 'SMITH, PAUL', ',' )-1)
)

 

returns Paul Smith

pradosh_thakur
Honored Contributor II

Re: Reorder text in a field

I am sorry. My bad. Missed to specify the delimitter

Capitalize(subfield(MM_CURR_SERV_OWNER,',',2)) & ' ' & Capitalize(subfield(MM_CURR_SERV_OWNER,',',1)) as MM_CURR_SERV_OWNER

Learning never stops.
7 Replies
Partner
Partner

Re: Reorder text in a field

In you load script add another column
Capitalize(
right(MM_CURR_SERV_OWNER,len(MM_CURR_SERV_OWNER)-Index( MM_CURR_SERV_OWNER, ',' )) & ' '& left(MM_CURR_SERV_OWNER,Index( MM_CURR_SERV_OWNER, ',' )-1)
) as MM_CURR_SERV_OWNER_FORMATTED

e.g.

Capitalize(
right('SMITH, PAUL',len('SMITH, PAUL')-Index( 'SMITH, PAUL', ',' )) & ' '& left('SMITH, PAUL',Index( 'SMITH, PAUL', ',' )-1)
)

 

returns Paul Smith

pradosh_thakur
Honored Contributor II

Re: Reorder text in a field

try below

 

Capitalize(subfield(MM_CURR_SERV_OWNER,2)) & ' ' &  Capitalize(subfield(MM_CURR_SERV_OWNER,1)) as  MM_CURR_SERV_OWNER

Learning never stops.
david_pearson
New Contributor III

Re: Reorder text in a field

thank you for this. it's almost there. with your example code i now get Smith, Paul Smith, Paul

 

any further suggestions?

pradosh_thakur
Honored Contributor II

Re: Reorder text in a field

@david_pearson  whose code did you try? It's not clear.

-Pradosh

Learning never stops.
david_pearson
New Contributor III

Re: Reorder text in a field

Capitalize(subfield(MM_CURR_SERV_OWNER,2)) & ' ' & Capitalize(subfield(MM_CURR_SERV_OWNER,1)) as MM_CURR_SERV_OWNER
pradosh_thakur
Honored Contributor II

Re: Reorder text in a field

I am sorry. My bad. Missed to specify the delimitter

Capitalize(subfield(MM_CURR_SERV_OWNER,',',2)) & ' ' & Capitalize(subfield(MM_CURR_SERV_OWNER,',',1)) as MM_CURR_SERV_OWNER

Learning never stops.
Highlighted
david_pearson
New Contributor III

Re: Reorder text in a field

works great. thanks. i tried the other users solution and this also worked. thanks for your help