The FileMaker Calculation Literal Explored

From Dwayne Wright PMP, PMI-ACP, CSM
Certified FileMaker Developer

WEB: www.dwaynewright.com
EMAIL: info@dwaynewright.com
TWITTER: dwaynewright
YOUTUBE: FileMakerThoughts

A calculation literal is a value within a calculation that does not change and has been entered in by the developer. A calculation literal, an expression and a reference value are the three ways you can supply a parameter to a FileMaker function.


Many times a calculation literal is used when you are placing a string of characters in a calculation saved as a test result. A literal text string within a calculation needs to be enclosed between quotation marks. For example say that you have a person name field and a birth date field and you wanted to make a calculation field return a birthday message. The calculation could be something like Person Name & “ birthday is “ & Birth date.

You can also define literal numbers or literal date strings. Literal number values do not have to be enclosed within quotes. A literal date value would need to be enclosed within quotes and be wrapped within a GetAsDate function.

Since calculations can be used in scripting, you can have a calculation literal supply the user a reference point. The Go To Layout script step for example could have a number of literal references. One example could be to go to a list view layout if the results of the search yields more than one found record or go to form view if just one matching record is found.

Case(
Get ( FoundCount ) = 1 and Get ( LayoutTableName ) = "Campaign"; "FORM_Campaign";
Get ( FoundCount ) > 1 and Get ( LayoutTableName ) = "Campaign"; "LIST_Campaign";
Get ( FoundCount ) = 1 and Get ( LayoutTableName ) = "Client"; "FORM_clients";
Get ( FoundCount ) > 1 and Get ( LayoutTableName ) = "Client"; "LIST_clients";
etc...
"")

As with most literal references, you can encounter problems if you change the name of the reference. You notice that I use a singular reference for the Campaign module but a plural reference for the clients module ( FORM_Campaign vs FORM_clients ). This type of mismatched naming convention is something you would want to avoid or fix. It doesn’t hurt the results actually but is an example of sloppy design. If I decided to rename all my layouts singular or rename them all plural, I would have to redo my calculation to bypass any errors!

© 2010 - Dwayne Wright - dwaynewright.com
The material on this document is offered AS IS. FileMaker Pro is the registered trademark of FileMaker Inc.