View Selection Formula - @Contains

Hi - I have a field called “Ticker”, and am trying to build a view such that it will only contain records that contain certain values in that “Ticker” field.

There are 95 different values for my field “Ticker” that I want the view to search for and show.

The only way I can think to word the “or” View Selection Formula is like this:

SELECT (@Contains(Ticker; “PBCT”)) | (@Contains(Ticker; “CVS”)) | (@Contains(Ticker; “QCOM”)) etc - going on for each of the 95 different Ticker possibilities.

Would anyone be able to suggest an easier way for me to write this formula, other than writing an @Contain for each of the 95 different values in my “Ticker” field?

Thank you so much in advance for any help you could provide.

Kind regards - Marni

Subject: View Selection Formula - @Contains

Slightly shorter, but obviously still some work to do:

SELECT (Ticker *= “PBCT”:“CVS”:“QCOM”:"…)

Subject: RE: View Selection Formula - @Contains

Hmmm - it is not giving me the full list of results.

Does *= mean OR? I definitely need an OR statement for the list of Tickers.

Thanks again - Marni

Subject: RE: View Selection Formula - @Contains

Yes, it means that any single match will do.

The only problem comes up, if a Ticker field contains multiple values, but is not set as multivalue fields. This operator only works on lists (and single values, which are lists consisting of one element).

Subject: RE: View Selection Formula - @Contains

Sounds good - I will make sure my Ticker field is set to allow multi values - this could indeed be the issue.

Thanks again!

Subject: RE: View Selection Formula - @Contains

Remember, that this might require you to update the existing documents! Just changing the field properties on the form does not affect documents, until they have been re-saved.

I also wonder how this field is filled. Those acronyms sound like they do have a meaning. How many possible values do you have in total? If this is not free text input, wouldn’t it be easier to specify what not to show?

I’m just wondering if I’ve ever seen a selection formula, that checks for 95 different possible values before …

Subject: RE: View Selection Formula - @Contains

The Tickers are stock symbols - we have thousands and thousands in our database. I’m trying to create a View that only contains documents with those Tickers that we hold in one of our Funds.

Another problem is that the list of 95 tickers changes from week to week, and since I’m putting this list into the Selection View formula, I’m the one who’s going to have to update it, instead of the user.

Is there anyway I can create some kind of Lookup Form that a user can edit that my View Selection Formula could reference instead?

Thanks so much again guys!

Subject: RE: View Selection Formula - @Contains

No way to do “real” lookups in a view selection, but there are a couple of alternatives.

First, you could try to do it with a search instead of a view selection formula, but due to the sheer number of values to pick from, that would probably not be a good idea.

Then you can programmatically update a view’s selection formula using a LotusScript agent. If you have the info as to which stocks are in the fund available in either one document or a couple of documents, the agent could retrieve that list (or rather an array inside LotusScript then) and build a new SELECT string from that.

It’s a pretty elegant way and works extremely well, if not used over the top (like changes every 5 minutes) and if their is no risk that the agent could be signed by someone who doesn’t have the right to execute it.

Does require some basic LotusScript skills, but there is a nice little example in Desinger help on NotesView.Selectionformula.

Subject: RE: View Selection Formula - @Contains

I’ll definitely look into that.Thanks much!

Subject: RE: View Selection Formula - @Contains

This operator only works on lists and single values

So what doesn’t it work on? It works on lists or single values. What else is there?

I’ve had just as much luck without the asterisk:

SELECT Ticker = “PBCT”:“CVS”:“QCOM”:"…

Subject: RE: View Selection Formula - @Contains

I think the point was that x*=y will not find partial matches, so it’s not a direct replacement for @Contains. For instance:

@Contains(FieldName; “xyz”)

will return true if FieldName contains any value any of which contains the substring “xyz”. If the field being tested in the original posting looked like it contained multiple values in the UI, but actually contained a semicolon-delimited single value, the formula would work with a bunch or ORed @Contains but not with the *= version.

EDIT - ADDED:

The no-splat version will work reliably when comparing a single value to a list, but not when comparing a list to a list unless the values happen to line up correctly. For instance, this statement:

“apples”:“bananas” = “aardvarks”:“apples”:“bananas”:“carrots”

will return @False because although both values from the LHS exist in the RHS list, the evaluation is done pair-wise, so it’s actually evaluating:

“apples” = “aardvarks”

“bananas” = “apples”

“apples” = “bananas”

“bananas” = “carrots”

The permuted version (splat) will return @True because it checks all of the possible value combinations.

Subject: RE: View Selection Formula - @Contains

Edit: Too late, once again …

What else is there? Well, what about a single value (technically) that holds two values (logically). A single value field containing something like “PBCT;CVS” will obviously not return, what you would want to, whereas @Contains still would. That was easy, wasn’t it?

“I’ve had just as much luck without the asterisk: SELECT Ticker = “PBCT”:“CVS”:“QCOM”:”…"

Well, maybe, if you pick your example carefully. The simple equality operator performs a pairwise equality check. If one of the lists is shorter than the other, the last element of the shorter list will be repeated until both lists are of the same length. Then, every value in the first list is compared to its counterpart on the same index in the other list. If at least one pair match is found, the return value is True.

“A”:“B”:"C:“D” = “E”:“D” ==> True

“A”:“B”:"C:“D” = “D”:“E” ==> False

“A”:“B”:"C:“D” = “E”:“B”:“D”:“C” ==> True

“A”:“B”:"C:“D” = “B”:“C”:“D”:“E” ==> False

The permutation equality operator on the other hand is not that picky. As long as any element in list one matches any element in list two, the return value is True.

“A”:“B”:"C:“D” *= “X”:“D”:“X” ==> True

As long, as one list is always a single value, there’s no difference.

“A”:“B”:“C”:“D” = “D”

is the same as

“A”:“B”:“C”:“D” = “D”:“D”:“D”:“D”

is the same as

“A”:“B”:“C”:“D” *= “D”:“D”:“D”:“D”

The one value in list two is always compared to every single element in list one. However, if there is the slightest chance, that your single value in list two COULD be a list as well, the permutation equality operator yields the more robust results (if this logic is what you want to achieve).

And it’s all in Designer help …

Subject: RE: View Selection Formula - @Contains

Thank you - that’s definitely better!

Subject: RE: View Selection Formula - @Contains

Cool, have a look in the “Date (flat)” view of this forum. Your response appears even before my posting. :slight_smile:

How did you know, what I was going to suggest? :wink: