Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
patriciabb
Partner - Contributor III
Partner - Contributor III

Remove last substring from a string

Hi there, I have a field (called GROUP) containing multiple strings like this one:

Group1/Group2/Group3/Group4/Group5

and so on.

I don't always have the same number of substrings (divided by the '/'), sometimes there are more than 5 and sometimes less than 5.

I'd like to remove from these strings the last subfield, intependently of the number of substrings.

 

Has anyone any clue about how could I get this done?

Labels (5)
1 Solution

Accepted Solutions
atoz1158
Creator II
Creator II

Hi

As long as you have at least two substrings this should work for you

Left(GROUP ,Index(GROUP,'/',SubStringCount(GROUP,'/'))-1)

Regards

Adrian

View solution in original post

4 Replies
Anonymous
Not applicable

use the formla: =SubField('Group1/Group2/Group3/Group4/Group5','/',-1)
it retreives the last subfield after the defined character from right (defining -1)

instead of hardcoded text use your data field

atoz1158
Creator II
Creator II

Hi

As long as you have at least two substrings this should work for you

Left(GROUP ,Index(GROUP,'/',SubStringCount(GROUP,'/'))-1)

Regards

Adrian

patriciabb
Partner - Contributor III
Partner - Contributor III
Author

Thanks, but that's not what I'm looking for, I wanted to keep the rest of the string, not the last one.

 

 

patriciabb
Partner - Contributor III
Partner - Contributor III
Author

Thank you, it worked perfectly!

I was assuming it had to do with the Index function.