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.

Calculation to parse text between semi-colons from one field into multiple fields

Featured Replies

I'm trying to take text from one field and break it into several other fields. The source field contains several words separated by semi-colons, kind of like the format of a CSV file. Each semi-colon represents the start of a new field. The problem is that the values between the semi-colons are not a standard number of characters or words so calculations like LeftValues, MiddleWord, etc don't seem like they will work.

I need a calculation that looks at all the characters from the first one in the field to the first semi-colon of the source field. Then the second calculation would take the values between the first and second semi-colons from the source field, and so on.

So the source field would be something like:

Blue 255; John; Apple Banana Orange

And the three new fields would each have a calculation that referenced the source field but only pick out one section

Blue 255

John

Apple Banana Orange

And it needs to work regardless of the number of words/characters in each section. Could someone point me toward the right function please?

  • Author

Ok, hopefully there is a much easier way, but I think I have an idea of how to approach this. I could use the position function to get the number of characters from the left of the first, second and third semi-colons, find the differences to calculate the number of characters in each field, then use the Left, Right and Middle functions to get the text. Is this the only way to go about this?

Your idea is correct, but this might be easier:

Substitute ( myField ; "; " ; ¶ ) converts each semicolon and the leading blank into a carriage return, which lets you use the MiddleValues function:

Substitute ( MiddleValues ( myField ; 1 ; 1 ) ; ¶ ; "" ), Substitute ( MiddleValues ( myField ; 2 ; 1 ) ; ¶ ; "" ) etc.

  • Author

I follow you on the first part, but could you explain what the second line is doing there please?

the syntax for MiddleValues is: MiddleValues ( text ; startingValue ; numberOfValues )

so it looks like the text you have "( myField ; 1 ; 1 )" in place of "text" , ¶ for the starting value and "" for the numberOfValues. I don't understand what that is doing.

[EDIT]

Nevermind, I just reviewed the help page for MiddleValues and see that it parses text between ¶s. I thought it could only take the middle # of characters specified between a numeric value for the first and last characters.

I follow you on the first part, but could you explain what the second line is doing there please?

the syntax for MiddleValues is: MiddleValues ( text ; startingValue ; numberOfValues )

so it looks like the text you have "( myField ; 1 ; 1 )" in place of "text" , ¶ for the starting value and "" for the numberOfValues. I don't understand what that is doing.

The result of MiddleValue has trailing carriage return, which you need to get rid of. This is achieved by wrapping the MiddleValues function inside

a Substitute, since FileMaker resolves a calculation from innermost to outermost.

The calculation may be more easy to read like this:

Let (

[

myVariable1 = MiddleValues ( myField ; 1 ; 1 ) ;

myVariable2 = substitute ( myVariable1 ; ¶ ; "" )

] ;

myVariable2

)

EDIT: Courtesy to raybaudi, who reminded me of GetValue, which has no trailing CR, simply make it GetValue ( myField ; 1 ), GetValue ( myField ; 2 ) etc.

The result of MiddleValue has trailing carriage return

So why not use GetValue ( ) ?

So why not use GetValue ( ) ?

Why not indeed? :hmm:

  • Author

even better! Thank you both :yep:

the substitute method from eos and the GetValue Rayaudi suggested will work quite easily. Thanks guys!

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.