Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
The largest groups of calculation functions in FileMaker Pro pertain to investigating and manipulating text. Unlike some groups of functions in which only a few are used on a regular basis, I'd say that nearly half of these text functions are of primary application and importance. So in this movie, I'm going to introduce you to the syntax of some of the core text functions. Let's get started right away by going into File > Manage > Database, and you'll see that we've got a field in here that's called TextCalc. It's already set up as a Calculation, but let's hit Options and clear out our Formula Entry window.
We can isolate the text functions in the upper right-hand corner by selecting Text Functions from the dropdown, and here you'll see we have quite a few of these functions at our disposal. These really break into a couple of groups. The first group is one that measures text and provides back a numeric output. So, for example, we've got one here that's called Length, and you see it's just got a single parameter. So you see I've got Length and then of course, the text parameter is highlighted. So let's choose CompanyName because we know that's a field that is a text field, and now in the case of Length, this is actually going to give me a numeric value of the Length, or the total number of characters of the data inside the CompanyName field.
So we want this Calculation result to be a Number. So we're going to hit OK and OK again, and now you see here we've got TextCalc on our layout, and in Browse mode we can see that it's dynamically evaluating the different values. We see up here is the CompanyName and we see the number being calculated differently for every record. So it's important to understand that when you're creating this Calc, it's just evaluating the value inside the fields that you're using as placeholders in your formula and only doing so on the current record.
The other thing that's important to note with length is that FileMaker considers spaces a character. So when you see something like 13 characters here, it's counting this comma and the space and the period in front of Inc. Keep that in mind when you're setting your own expectations for what you calculation's results will be. So back in the TextCalc dialog, hit Options again, another one I want to show you is Word Count. We'll go back to Text functions. So you see here we've got Length will give us the total number of characters and likewise, we've got WordCount will give us the total number of words in a string.
So let's try CompanyName again, and of course, that's going to give us the number because it's counting the number of words. So let's hit OK, and if we go all the way back to Record #1, you see we've got one word there, but this is important here. I wanted to show you this one; we've got a Radley & Friends, but how many words does it count? Well, it counts two words there. So in the case of words, it doesn't count delimiters like ampersands and things like that. Now, if you're doing word counts on a Phone Number field, it will recognize the fact that there's a number on each side of one of these delimiters, in this case, a dash, and it's going to recognize this as numbers.
It does that for dates and phone numbers. So in this case, if we put in here, it would give us one word. But because this is text, and it's using an ampersand in this case, it's considering that two words. So a little something to keep in mind there on how FileMaker treats those word delimiters. So you see we've got a couple of examples of functions that count either characters or words, and I'm going to show you another one that is pretty popular. This one is called PatternCount.
So this one also counts, but instead of counting words or counting characters, what it's going to count is a string of values that you're putting into this parameter. So first, we're going to pick, let's say, CompanyName again, and now it says here put in a search string parameter. So what we're going to do is we have to put in some kind of text that we're going to look for within the CompanyName, and it's going to count how many times it sees that. This type of calculation is used to nest inside of other calculations, which you might find useful as you get into more intermediate or advanced calculation writing.
But just to give you an idea, from an accounting perspective, here we have a Search string, and we're going to wrap this in quotations because anytime you put any text values in a calculation function, you have to denote them as text by wrapping them in a quotation. Here I'm going to put R and leave it as number, hit OK, and let's go back into our values here. So no letter R's, back in Browse mode, and here you notice we have 2. So one thing I wanted to point out here is that we've got 2; one of them is a capitalized R and one of them is a lower case r.
It still counts R so as you can see that particular function is not case-sensitive. There are some functions that are case-sensitive; PatternCount is not. So you want to take that into account sometimes you might be just trying to isolate specific case-sensitive patterns, and then you would have to use other functions for that. Now, keep in mind we just put in an R in this case, but what we could have done is put in a whole word, for example, So really it's whatever string you want to put inside there. Now you see we're finding that one word in both of those occurrences.
Now there's another function you might find useful, and we're going to use this in another area where you see a calculation dialog appear. If we go into the CompanyName field, notice here we've got the Calculation Value option chosen. We hit Specify. That's because we've got a calculation in here, and this one is called trim, which is just another one of the text functions, and what trim's role is just to take any leading spaces or trailing spaces and trim them out and just leave whatever text is left that's not spaces. It doesn't leave anything in between words or anything like that but just leading or trailing. And because we've got this set up as an Auto-Enter calculation and also because we have removed the check box from the default, Do not replace existing value, and again, that syntax is a little cryptic, but what that means is do we want the formula that we just put inside this dialog to be applied to the values that we're typing in the field, or do we not? So in this case, we do, so we leave it unchecked.
If we do not, then we check it. What kind of functionality does that give us? Well, if you go inside the CompanyName field, see I've got my curser there, if I put a bunch of spaces after it, and the reason this might be useful is because if you ever import data in from another source, other non-FileMaker database applications will have minimum character length so you've got the data, and then it'll add a bunch of spaces on to the end of it and sometimes even at the beginning. And this might not really jive for you the data inside your database.
So as you see here, I've added a bunch of spaces, and now I'm going to commit the record, but now when I click back in, you notice that FileMaker's has shaved all those spaces off the end. So that's how the Trim function works, but at the same time, it's a useful thing to use inside the Auto-Enter Calc dialog. And finally, I'm going to show you him to show you a series of functions inside the text family that deal with extracting words or characters from other text values, or fields. If we first close the window and look, notice that all of our records have a Full Name field.
This is kind of a common occurrence; sometimes you might be importing in from another source and a common mistake that some developers, rather application designers, make is that they don't break down the data into the smallest bits of data possible. So a lot of times people will just say, oh name, okay, we're going to put full name. The problem is you want to break that it into First and Last Name because let's say you were writing a letter and you want it to say, Dear Joe. Well unfortunately, you don't have any data, and your database at this point, you just have to call him Dear Joe Smith, and that doesn't really work. So what we're going to do is we're going to come up with a couple calculations that will extract the first word out of the full name and put it into the First Name field, and we're going to take the second word out of the Full Name field and put that into the Last Name.
Now I'm going to show you another area where the Calculation dialog can be used, and that is under the Records menu, you see there's something called Replace Field Contents. Now this is a great tool to apply batch updates to whatever fields you have in your current found set. You see here that we've got 1,523 records. Well, before you choose any kind of Replace Field Contents, you want to make sure that you're choosing the fields first that you want to apply these batch updates to. So we click the First Name field, go back under Records to Replace Field Contents, and I could just have it replaced the value from the record I'm currently in, throughout all of the different records in the Found set, but we're going to fastforward down here to the Replace with calculated result, because we've got a Specify button which of course invokes the Specify Calculation Dialog.
So in this case, I want to show you couple of functions real quick here. You see this whole family of Left, LeftValues, LeftWords. You also have Middle, MiddleValues, MiddleWords and then Right, RightValues and RightWords. All nine of those together make up a pretty huge chunk of all of the different text functions, and if you understand how one of them work, you'll understand how they all work. So let's take a look at how Left would work. So in the case of Left, you have two parameters. Put in the field that's going to have the text value, and then you tell FileMaker how many characters you want to extract from the Left.
So in this case, I could say Customer Full Name and give me 1234. The thing is I don't know how many characters are going to be in this person's name each time. So in addition to have been able to extract characters using Left, Middle or Right, I've also got LeftWords, which is perfect for our task here. So I select Customer Full Name and add that as my text parameter. Then I tell it what number of words I want to extract from the Left, and then I'm going to say 1. So we hit OK, and now what the Replace Field Contents function will do, after I hit the Replace button, is it's going to go through every record in the Found set, one at a time, and it's going to perform this function.
So essentially what it's going to do is extract the first name out of the Full Name field and put it into the First Name field. So let's hit Replace, let it do it thing, and you see now every record in the database has a First Name. And similarly, we can do the same thing to the Last Name field, but what we have to do is make sure in the first record of our Found set because that's where the Replace Batch function is going to start. We want to include them all. So quickly we'll go in here, Text Functions, and then this time, we're going to say it Right.
So in case of Right, we're just going to pull. This would give us right number of characters. Of course, we could count those out. But we're going to instead use words because then we don't have to worry about how many characters, and we'll simply say Full Name, number of words, and we're just going to pull one for the Last Name, so now we hit OK. Hit Replace again, and now we see all of our records have extracted both first and last names. So you see here you can use any calculation function, but in these examples we used text functions, in both the Auto- Enter Calculation dialog and also under the Replace Records using the replace records with calculated results that also use the Specify Calculation dialog.
So it'll be good to get familiar with these functions because they're going to be used in quite a few areas within FileMaker Pro. In this movie we focused on really the core text functions, the ones that are used most frequently. But it's best to become adept at using these functions without needing to refer to the reference as a source. So the more you can write these things free flow or the more experience you get, the better. So do your best to apply these functions as often as you can throughout your FileMaker solution.
Get unlimited access to all courses for just $25/month.Become a member
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.
Your file was successfully uploaded.