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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

load only last 2 words from a field

I'm building a demo app from client data and they're asking me to only show a portion of each project name in the app. For example, if a project name is shown as "Help the Homeless in DC", they want to only show "in DC" so as to not give away the source of the data. I can easily right-trim the data but it looks kind of messy so my preference is to grab only the last 2-3 words of the project name. Thoughts?

Thanks,

Kevin

4 Replies
Not applicable
Author

Subfield could work although you would need to know how many words you have or setup a sount of the delimiter (space in this case), try:

subfield(projectname,' ',4)&" "&subfield(projectname,' ',5)& as ShortName,


in your load script (assuming your project name field is 'projectname'

pbaenen
Contributor III
Contributor III

You can use substringcount to figure out how many fields you have.

subfield(vMyField, ' ', substringcount(vMyField, ' '))
& ' ' &
subfield(vMyField, ' ', substringcount(vMyField, ' ')+1);

hector
Specialist
Specialist

Hi, this is a little test, maybe it will work for your needs

rgds Wink

rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

You can use subfield with a negative index to extract words from the end of the full name.

subfield(project, ' ', -2) & ' ' & subfield(project, ' ', -1) as ShortName

-Rob