Although they don't come first in the function list, number functions are the most obvious application of calculations. Since most people easily understand them, number functions are a logical place to start. A lot of the concepts you'll learn for number functions apply to other functions as well.
10.1.1. Number Operators
Operators, along with fields, constants, and functions, are one of the basic building blocks of a calculation. FileMaker has five operators that specifically apply to numerical calculations, the same five that you probably already know:
Section 184.108.40.206 explains how to use these operators in detail. In your day-to-day work with FileMaker, you usually use these operators to calculate the numerical values in your fields.
Note: If you're new to calculations, you'll want to get a handle on the material in this chapter before proceeding. But if you've worked with logical tests before, you can skip straight to Chapter 11.
Say you're an event planner and you always plan for 10 percent above the expected number of attendees. Use this calculation to find your fudge factor:
Sum ( Attendees::Confirmed ) * 1.1
10.1.2. Number Function Types
FileMaker also gives you dozens of functions that do special things to numbers. Because there are so many number functions, the function list breaks them up into smaller groups. The groups have descriptive names, so you can drive right to the group you need (or skim by them without looking, if you might be traumatized if you accidentally saw a sine or cosine function). The functions you use with your numeric data are:
As you saw on Section 9.2.4, every number function expects one or more parameters, each a number value, and all the number functions return a number result. Here's how to put them to work:
Note: This book doesn't cover the financial and trigonometric functions, which have highly specialized uses. If you need to use these brawny functions, you probably have the mental muscle to decipher the technical terms in FileMaker's Help file, where you'll find them explained.
Some calculations demand a high degree of precision, like those that track radioactive isotopes or other scientific data with lots of places following the decimal point. FileMaker comes prepared with the SetPrecision function. This function extends FileMaker's default precision of 16 decimal places, up to a maximum of 400. If you need more precision, you add a SetPrecision function to the calculation that produces the value that requires precision. You can use SetPrecision with all other numeric functions, except trigonometric functions, which don't accept this extended precision. See Figure 10-1.
The SetPrecision function requires two parameters. The first parameter is a number, or any expression that results in a number. The second is the number of decimal places you want to see.
This calculation would return Pi with 3 decimal places:
SetPrecicion( Pi ; 3 )
This version would show 100 decimal places:
SetPrecision( Pi ; 100 )
Note: The SetPrecision function affects your calculation's result, but not the way FileMaker displays it. To save space on your layout, you can format a very precise calculation to show only a few decimal places until you click the field, when you see the stored value (Figure 10-1).
Part I: Introduction to FileMaker Pro
Your First Database
Organizing and Editing Records
Building a New Database
Part II: Layout Basics
Advanced Layouts and Reports
Part III: Multiple Tables and Relationships
Multiple Tables and Relationships
Advanced Relationship Techniques
Part IV: Calculations
Introduction to Calculations
Calculations and Data Types
Part V: Scripting
Part VI: Security and Integration
Exporting and Importing
Sharing Your Database
Part VII: Appendixes
Appendix A. Getting Help