The Structure of a Calculation

If you accidentally mistyped or misspelled a field name in the example above, you already know that FileMaker is a little picky about how you create a calculation. Clearly, syntax (the order of elements and the punctuation in your calculation) matters. Still, a calculation is really just text, arranged in a specific order. Here you learn the basic parts of a calculation through a couple examples.

Note

Calculations are often called calcs for short, or formulas. Although there are some slight differences between a calculation and a formula, people usually use the terms interchangeably. Sometimes, a formula is so useful, or common, that FileMaker defines it as a reusable formula, also known as a function (see Functions).

A calculation can be short and simple:

	Pi * Diameter

Or it can be more complicated:

	Case ( Shape = "Circle" ; Pi * (Diameter/2) ^ 2 ;
	Shape = "Rectangle" ; ShapeLength * Width ;
	)

Note

FileMaker won’t let you give a field the same name as an existing function. The field containing the length of a rectangular object has the unwieldy name “ShapeLength” to avoid confusion with FileMaker’s length function. The field name “Width” is fine, because there’s no width function.

In fact, calculations can be really long and complicated if you need them to be—up to 30,000 characters. Practically speaking, the only limit on the complexity of a calculation is your patience for creating it.

Get FileMaker Pro 9: The Missing Manual now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.