Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
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,

1 Solution

Accepted Solutions
Colin-Albert

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

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

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

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

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

rwunderlich
Partner Ambassador/MVP
Partner Ambassador/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