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

Announcements
Qlik GA: Multivariate Time Series in Qlik Predict: Get Details
cancel
Showing results for 
Search instead for 
Did you mean: 
mertez
Contributor III
Contributor III

[resolved] tMap Expression filter - compare substrings with variable length

I am looking to compare a fixed string with a variable string that can be of different sizes. Let's say that I want to filter rows that matches the following criteria:
Expression filter:
"abcd".compareTo(a.substring(0, 4)) // where a is a string with variable length

The problem arrises when a="ab" or whenewer its length is lower than 4 characters. In this case "index out of bound exception" is thrown.

I can solve this with first chechking the variable string lenght but I am looking for a cleaner solution.
Labels (2)
1 Solution

Accepted Solutions
mertez
Contributor III
Contributor III
Author

I have found a better solution in a library StringHandling from Talend. Above problem can be solved with INDEX method which rerutns a starting position of the compared string.
ex:
StringHandling.INDEX(a,"abcd")
same but in Java:
a.indexOf("abcd")

View solution in original post

1 Reply
mertez
Contributor III
Contributor III
Author

I have found a better solution in a library StringHandling from Talend. Above problem can be solved with INDEX method which rerutns a starting position of the compared string.
ex:
StringHandling.INDEX(a,"abcd")
same but in Java:
a.indexOf("abcd")