Skip to main content

QlikView App Dev

Discussion Board for collaboration related to QlikView App Development.

Announcements
QlikWorld 2023, a live, in-person thrill ride. Save $300 before February 6: REGISTER NOW!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Trim last part of text field with variable lengths

Hello,

I am trying to cut the last part of the field that is the last instance of an underscore ("_"). For instance, I have a field with the 2 values below:

  1. CREDIT_ONLY_LAX
  2. RET_LINE_WITH_CREDIT_LS_GB

I want to cut the "_LAX" from the first example and the "_GB" from the second example. The result would then be:

  1. CREDIT_ONLY
  2. RET_LINE_WITH_CREDIT_LS

Any help would be great. My difficulty here is that it cannot be hard coded such as left(field, len -3) as it could range from 2-5 characters that I'm trying to cut off.

Thanks!

1 Solution

Accepted Solutions
marcus_sommer
MVP & Luminary
MVP & Luminary

Try: left(Field, index(Field, '_', - 1) - 1)

- Marcus

View solution in original post

3 Replies
marcus_sommer
MVP & Luminary
MVP & Luminary

Try: left(Field, index(Field, '_', - 1) - 1)

- Marcus

sunny_talwar

Try this:

Table:

LOAD Left(Field, (Len(Field) - Len(SubField(Field, '_', (Len(KeepChar(Field, '_')) + 1))) - 1)) as [New Field],

  Field;

LOAD * Inline

[Field

CREDIT_ONLY_LAX

RET_LINE_WITH_CREDIT_LS_GB

];

Not applicable
Author

Thank you to both!