FileMaker Function of the Week: Case

FULL CITY CONSULTING STARTED a FileMaker function of the week blog post two weeks ago, and explored the case function for their first post:

In the above example you’re effectively asking FileMaker if 5 is less than 6. If FileMaker determines that five is indeed less than six, it will show you the phrase “all is well”. Should FileMaker believe that 5 is not less than 6, it will display “uh oh.” All well and good when your needs are simple. But what do you do when your needs aren’t so simple? What can you do when you need to check for a variety of conditions? While it is possible to start nesting If functions inside of one another, it’s highly error prone and difficult to unravel. Case ( test1 ; result1 {; test2 ; result2 ; … ; defaultResult} ) Drop a Case function into a calculation and you’ll get something like you see above (this one has been reformatted a bit to improve readability). You can think of it as a way to list a series of Ifs. FileMaker will start with the first test. If the test is true, FileMaker will show the first result and ignore the rest of the function. If that first test is false, FileMaker will skip over the first result and look at the second test. If that second test is true, FileMaker displays the second result, if it’s false it moves on. FileMaker examines each test/result pair until it finds a test that is true. There is no hard limit to the number of test/result pairs a Case function can include. Should FileMaker get through all the tests and find that none of them are true, it will display a default result if you’ve chosen to include one. Let’s look at a real example.

The case statement is a very powerful way to work through multiple ‘if’ possibilities, stopping at the first match or continuing on till all possibilities are exhausted.  Check out this new weekly feature if you are still new to FileMaker functions, need to learn some of the more arcane functions, or even if you just need a reminder.  There’s always something to learn, it seems.

via FileMaker Function of the Week: Case.

 

Liked Liked
Need FileMaker Development Help? Or to purchase FileMaker Software?
Contact FM Pro Gurus for help