Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
aambasht1626789554
Contributor
Contributor

check if the input string is in the list of strings

I have a context parameter context.input_cities with values 'chicago','new york'

How do i check if the input string is in conext.input_cities?

Labels (4)
6 Replies
gjeremy1617088143

Hi, Maybe you can use tFixedFlowInput or tRowGenerator to read your input as a string then you can use tNormalize component to transform your coma separated value input into a flow and then you can do a lookup with this flow.

Send me love and kudos

aambasht1626789554
Contributor
Contributor
Author

thanks!is there any easy function to use like stringhandling.equals?

 

gjeremy1617088143

yes, but you can but you have to set this fonction for each value of your list, with full component solution I provide(these components are really easy to understand) it will be maintenable and don't need to be change if you're doing change in the list

aambasht1626789554
Contributor
Contributor
Author

i was asking if there was a function that could take take context.input_cities and input string as two arguments and perform the search

_

Anonymous
Not applicable

Using the String.contains("value") function?eg:

context.input_cities.contains(row1.columnName)

gjeremy1617088143

The contains way is a solution, but it is prone to false positives: it will match a sub-string like , or space or new etc...

you can make a custom routine with split string method :

 

String[] splitString = ((your list).split(","));

for (String string : splitString) {

if (string.equals(your input)) {return true;}

}

return false;

 

and for better performance you can separate the split from the search, to split only once the String.