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

Announcements
Discover how organizations are unlocking new revenue streams: Watch here
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Get last piece of a string

Hi, I have a lot of strings of different lengths but in same format:

AA12 - ABCD: XXX - SC - IWANTTHISSTRING

BB34 - EFGH: YYY - SC - ALSOTHISONE

Is there a way to retrieve the last piece of these strings? In this case I want "IWANTTHISSTRING" and "ALSOTHISONE" as results.

I have tried TextBetween('SC - ', '') but it does not work with empty-string as second argument... Can I count occurences of "-" maybe?

Thanks

Mikael

1 Solution

Accepted Solutions
Not applicable
Author

Hi Mikael,

you can use SubField(VALUE, '- SC - ', 2) expression, where VALUE contains entire string and with assumption that '- SC - ' appears in the string only once.

Without that assumption put parameter value -1 instead 2; that will always return last substring.

regards

View solution in original post

2 Replies
Not applicable
Author

Hi Mikael,

you can use SubField(VALUE, '- SC - ', 2) expression, where VALUE contains entire string and with assumption that '- SC - ' appears in the string only once.

Without that assumption put parameter value -1 instead 2; that will always return last substring.

regards

Not applicable
Author

Hi Mikael,

Is the string you are after, ALWAYS after the 3rd "-" ?

I think I know a way in excel to do this, and therefore logically, a way to do it in QV...

Kind regards,

Rich