Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements
QlikView Fans! We’d love to hear from you.
Share your QlikView feedback with the product team… Click here to participate in our 5-minute survey.
Rules, plus terms and conditions, can be found here.
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,

Tags (2)
1 Solution

Accepted Solutions

Re: Extract the last word

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
]
;


11 Replies
lironbaram
Honored Contributor II

Re: Extract the last word

hi

something like

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

should do the trick

Re: Extract the last word

or

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

Not applicable

Re: Extract the last word

An error appears. It says "inadequate Object memory"

Not applicable

Re: Extract the last word

This expression gives me the last letter of the last word

Re: Extract the last word

Can you share an example of your input?

Not applicable

Re: Extract the last word

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

Re: Extract the last word

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
]
;


Re: Extract the last word

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

Re: Extract the last word

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

Community Browser