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

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
TY3
Contributor
Contributor

How to do an IN operation using tMap expression

I want to do an IN condition in tMap expression i.e. check if the value of a column falls in a list of values.

 

e.g. my input row contains a column STATE and i want to allow data belonging to only certain states, let's say CA, NY and NC, to flow downstream as ouput from tMap.

 

I know i can do something like this in tMap expression filter

row1.STATE =="CA" || row1.STATE =="NY" || row1.STATE =="NC" .

 

I actually do not want to hardcode my list in the expression, but,  instead pass them as a context variable. Also, my list of values is not constant; it can go up or down.

 

So, i was wondering if there is something like

row1.STATE in (context.desired_states) that i can do where i can set the value of context variable desired_states as "NY","CA",'WA" . This gives flexibility to change the list by just updating the context variable value instead of chaging the code everytime i want to add or remove a value from the list.

 

Labels (3)
1 Solution

Accepted Solutions
TRF
Champion II
Champion II

As soon as you have a context variable with valid states such as "NY","CA",'WA" you can use the following expression:
context.desired_states.contains("\"" + row1.STATE + "\"")

View solution in original post

1 Reply
TRF
Champion II
Champion II

As soon as you have a context variable with valid states such as "NY","CA",'WA" you can use the following expression:
context.desired_states.contains("\"" + row1.STATE + "\"")