Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Posting on Qlik Community is temporarily paused for some users. Thank you for patience and we'll update you soon!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Extract the last word

Hi Everyone !

I need to extract the last word in a field. Does a function exist to do that ?

Thanks,

Labels (1)
1 Solution

Accepted Solutions
Colin-Albert
Partner - Champion
Partner - Champion

Try this, it returns the last word OK for me.



Data:
LOAD
subfield(Full_Address, ' ', -1) as LastWord,
*
INLINE [
Name, Full_Address,
James, 3 rue Victor hugo 60100 CREIL,
Nick, 6 rue Lucien charton 60160 LAIGNEVILLE,
Lena, 9 rue Henri Breuil 60600 CLERMONT,
Jenny, 12 rue des frères grimm 60180 NOGENT
]
;


View solution in original post

11 Replies
lironbaram
Partner - Master III
Partner - Master III

hi

something like

subfield(YOURFIELD,SubStringCount(YOURFIELD,' ')+1)  as LastWord

should do the trick

sunny_talwar
MVP
MVP

or

SubField(Fieldname, ' ', -1) as LastWord

Not applicable
Author

An error appears. It says "inadequate Object memory"

Not applicable
Author

This expression gives me the last letter of the last word

sunny_talwar
MVP
MVP

Can you share an example of your input?

Not applicable
Author

Example :

LOAD * INLINE [

Name, Full_Adress,

James, 3 rue Victor hugo 60100 CREIL,

Nick, 6 rue Lucien charton 60160 LAIGNEVILLE,

Lena, 9 rue Henri Breuil 60600 CLERMONT,

Jenny, 12 rue des frères grimm 60180 NOGENT]

I would like to extract the last word of Full_Adress which refers to the town.

I don't know how to join a Qlikview file here

Colin-Albert
Partner - Champion
Partner - Champion

Try this, it returns the last word OK for me.



Data:
LOAD
subfield(Full_Address, ' ', -1) as LastWord,
*
INLINE [
Name, Full_Address,
James, 3 rue Victor hugo 60100 CREIL,
Nick, 6 rue Lucien charton 60160 LAIGNEVILLE,
Lena, 9 rue Henri Breuil 60600 CLERMONT,
Jenny, 12 rue des frères grimm 60180 NOGENT
]
;


sunny_talwar
MVP
MVP

Yup, I don't see why it wouldn't work

rwunderlich
MVP
MVP

I believe Sunny T gave you the correct answer. But you did not code the space between ' '.  It will work if you include the space.

-Rob