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

summary of string field full words

Hi Everyone,

I have a text field with words and sentences in (i.e. a full commentary field).  I want to create another field that has a summary of said field with a limit of words or length but remaining as full words.  If I use the left() function obviously it counts characters so all of my summaries end with broken words.  Can anyone think of a simple solution?

As an example,

'The quick brown fox jumped over the lazy dog'  let's say I want to restrict this field to a maximum of 12 characters but only include full words.  So I'm happy if it is less than 12 characters as long as it has full words up to that point.

Thanks

Gareth

3 Replies
danielrozental
Master II
Master II

you could keep the first 12 characters, find the last space and then keep the text up to that space.

Something like

=left(var1,index(left(var1,12),' ',-1))

Not applicable
Author

Hi Garteh, you could also try the following, that finds the next space of the truncated string and completes the last word.

Regards

=left(vstr,12)  & subfield(subfield(vstr,left(vstr,12),-1),' ',1)

Not applicable
Author

Thanks both very helpful answers!!