Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

FMP 6 - Using or in If() calculations...

Featured Replies

Hi

Is it possible to use the or operator in in calculations?

So if you have a calculation like this...


If( Status(CurrentUserName) = "James" or Status(CurrentUserName) = "John", "True", "False")

I've just tried it and it doesn't seem to be working.

I realise I could use Case() rather than nested If() statements, and I am doing so in the meantime.

But I just wondered why I couldn't get it to work.

Any ideas?

Thanks

Batfastad

Hi, indeed it is possible and your calc is correct.

One thing to ensure is your calculation is not stored.

You can use "or" and any one of the logical operators with If(), Case() or any other function. It helps to remember that in FMP, True is 1, and False is 0. This allows some neat shortcuts in calcs, e.g. instead of:

Case ( a = b ; number ; 0 )

you can write:

number * ( a = b )

  • Author

Yeah I think I may have forgotten to switch the calculation to unstored.

Is there a limit to the number of 'or' operators you can have in an expression?


If(Name = "John" or Name = "James" or Name = "Mike" or Name = "Barry", "true", "false")

Thanks

Batfastad

There's no limit that I know of, but it does get tiresome, so at some point you'd want to switch to PatternCount() or Position(), e.g.

Case (

Position ( "John James Mike Barry" , Name, 1 , 1 ) ,

"true" ,

"false"

)

  • Author

So doing...

Position("John James Nick Barry"

Having the space in there in effect does the 'or' bit?

How does that work?

Why doesn't it search the field for the text "John James Nick Barry" all in one string?

Thanks

Batfastad

It searches the string for the field, not the other way around (see the Position() syntax in FMP help). The space is there to prevent a false match, e.g. "PeterRyanNellie" are false match for Terry and Anne.

  • Author

Ah so the position returned, is the position in string, not the position in field of the string.

Never realised that and I've been using Position() for years.

It depends - you could have:

Position ( field1 ; field2 ; 1 ; 1 )

To put it in general:

Position ( textToSearchIn ; stringToSearchFor ; start; occurrence )

  • Author

Aha

I get it now.

Thanks for all your help guys.

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.