How to use FIND() in an IF() statement
-
I'd like to be able to hide a group within a component based on the value of a text list variable (OPENING!TYPE) users select.
Here is the IF clause I am using for the groups "Hidden" attribute:
=IF(find("SINGLE",OPENING!TYPE),FALSE,TRUE)Which says "If the string "SINGLE" is found in the attribute value for "OPENING!TYPE", return FALSE making the group not hidden, otherwise return TRUE making the group hidden.
The problem is that FIND() returns a number for where it found the search string. That is fine for when it successfully finds the search string because any positive number evaluates to true. BUT when it does not find it, it returns something like
Not found; SINGLEWhich does not evaluate to FALSE.
So, how can I use FIND() to return TRUE or 1 if it finds the search string and FALSE or 0 when it does not?
Thank you.
-
Not tested, but maybe:
=IF(find("SINGLE",OPENING!TYPE)>0,FALSE,TRUE) -
find needs to return a value, a position. so if if there is no match it fails. Since there is no error catch procedure, it is not possible to
IF(find("SINGLE",OPENING!TYPE)>0,FALSE,TRUE) unless "SINGLE" exists, can only be true or an error -
Well that stinks. Is there any way to test for an error. Will Jim's solution work?
-
@hank said:
Well that stinks. Is there any way to test for an error. Will Jim's solution work?
You could use LEFT and EXACT.
=EXACT(LEFT(OPENING!TYPE, 6), "SINGLE")or a simple IF
=IF(LEFT(OPENING!TYPE, 6) = "SINGLE", TRUE, FALSE)or maybe even
=IF(OPENING!TYPE = "SINGLE", TRUE, FALSE) -
Thank You Jim!
So how about if I wanted to find out if the string "SINGLE" exists anywhere in the string?
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better π
Register LoginAdvertisement