Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Trim last two characters

Trying to trim the last 2 characters (could be text or number) from a field with a variable number of total characters.  Could be staring with 200000WS and want 200000 as the result, or 789ABC123456YT4X and want 789ABC12345YT as the result.  Will index work for this?  I thought Left ([Item_number], index([Item-number],'')-2) might do it by jumping back 2 spaces from the the first balnk (the end of the string) but it returns the whole string.

1 Solution

Accepted Solutions
Alexander_Thor
Employee
Employee

That is strange. Attached is a sample application that does what you want, trims 2 characters from the right.

Press Ctrl + E inside the app to see the script.

View solution in original post

4 Replies
Alexander_Thor
Employee
Employee

Try left(YourField, len(YourField)-2)

Anonymous
Not applicable
Author

No, it doesn't seem to work either.  I still get the entire field.

Alexander_Thor
Employee
Employee

That is strange. Attached is a sample application that does what you want, trims 2 characters from the right.

Press Ctrl + E inside the app to see the script.

Anonymous
Not applicable
Author

Thanks a bunch Alexander, I got it.