Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

How to check if a value exist in a listbox

Dear Community,


with an expression i simply want to check if a value exists inside a listbox.

How can this be done?

Example:

Data: 

Load *,DepthSN As DepthSN_New Inline [ 

Producer, DepthSN 

p1,aaa 

p2,bbb 

p3,ccc ]; 

How to check that the value 'aaa' exists inside 'Data'?

1 Solution

Accepted Solutions
Clever_Anjos
Employee
Employee

Count({<DepthSN ={"aaaa"}>} DepthSN ) > 0

View solution in original post

4 Replies
sunny_talwar

You can use a expression like this in a list box:

=If(SubStringCount(Concat(DISTINCT DepthSN,'|'), 'aaa') = 1, 'aaa exists', 'aaa does not exist')

This will change results based on your selection. So for instance if you don't select 'aaa' in your list box it will say aaa does not exist. If you don't want that you can change the expression to this:

=If(SubStringCount(Concat({1}DISTINCT DepthSN,'|'), 'aaa') = 1, 'aaa exists', 'aaa does not exist')

HTH

Best,

Sunny

Clever_Anjos
Employee
Employee

Count({<DepthSN ={"aaaa"}>} DepthSN ) > 0

Anonymous
Not applicable
Author

Thanks for your answer,

unfortunately concat is not good, if you have million of rows

sunny_talwar

I think you are right. Clever Anjos‌'s solution seems to be much more efficient.

Best,

Sunny