Skip 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.

Evaluate a field for an instance of a text string

Featured Replies

  • Newbies

I have a field that contains a variety of data. I need to know the format for a function that would evaluate the field for the text string that is somewhere in the field (not exclusive) but is within the field. If the string is present within the field, than "x" if not than "y"

If( Position ( textfield ; "your text string to find" ; 1; 1 );"x";"y")

It sounds like you need to look at the Position() function. A nonzero value occurs when the match string has been located.

Either Position() or PatternCount() function can be used for this.

  • Newbies

By "not exclusive" I'll assume that the text string you are searching for may or may not appear in the field. So in A number of records you will have (A - B ) records where the text appears (B being the number of non-occurances).

The IF and POSITION functions will certainly give you your X or Y results.

Edited by Guest

The IF and POSITION functions will certainly give you your X or Y results.

Point is - so will PatternCount() as Comment suggested and Case() can be used as well.

Case ( PatternCount ( text ; "this" ) ; "x" ; "y" )

All that needs to happen is to produce a boolean true (1 or greater). It doesn't matter how many times the "this" would appear.

I believe that JT (-Queue-) once conducted a study over the speed differences between PatternCount() and Position(). He supposed Position() would be faster because it didn't have to count all instances and would stop when first instance was found whereas PatternCount() would need to evaluate the entire field before returning a result. I don't recall his results offhand but I think he was surprised that his supposition didn't necessarily hold true.

I believe that JT (-Queue-) once conducted a study over the speed differences between PatternCount() and Position(). He supposed Position() would be faster because it didn't have to count all instances and would stop when first instance was found whereas PatternCount() would need to evaluate the entire field before returning a result. I don't recall his results offhand but I think he was surprised that his supposition didn't necessarily hold true.

I'd love to see those results if you're able to dig up the link.

I will look for that thread over the holiday, Tom. Truth is ... spending some of my holiday reviewing JT's threads sounds fun to me. :wink2:

  • Newbies

Point is - so will PatternCount() as Comment suggested and Case() can be used as well.

Much earlier FMP versions had problems with imbedded multiple IF statements and Case was introduced to address this. Didn't think to replace IF with CASE for a single occurance - thanks for that!

As for PatternCount - I can't recall ever having to use it - but then most of the FMP work I have done to date has had little text processing involved. Recently I had to devise a function to extract email addresses from "bounce backs" (dead) so a client could update their records after they sent their regular newsletter out. So, after some experimentation, CASE, MIDDLE and POSITION did the job on the bulk (about 99%) of the bounce backs.

I can see that text processing is going to become more and more of a requirement - interesting times ahead :

Create an account or sign in to comment

Important Information

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

Account

Navigation

Search

Search

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.