Database Reference
In-Depth Information
any chance you'll want to add some conditions to the statement later on. Instead of editing an
If() expression later, you can save time by using Case() from the start.
The same calculation using Case() (and minus the helpful comments) looks like this:
Case (
Get ( CurrentDate ) > Date Due and Sum ( Line Items::Extended Price ) >
allPayments ;
Sum ( Line Items::Extended Price ) + ( Sum ( Line Items::Extended Price )
* .05 ) ;
Sum ( Line Items::Extended Price )
)
NOTE
With a single condition and standard result, the syntax for If() and Case() are the same. So if you
do need to change an If() statement to Case() later, then simply change the word “If” to “Case,”
and add the new conditions.
This calculation works as advertised, but it has a couple of weak points. First, it has to calcu-
late the total amount due three times . That's twice too many places to make typos and places
to edit the Sum(Line Items::Extended Price) expression if you change the calculation
later.
Second, allPayments is an unstored calculation based on the sum of related records. That's
one of the slowest things you can ask a calculation to do. It may not matter much in this data-
base, but in a more complicated situation, a calculation like this could slow FileMaker to a
crawl.
In the next section, you'll learn how FileMaker helps you write leaner calculations that are
easier to read—and quicker for FileMaker to work through.
The Let() Function and Variables
The Let() function creates a temporary holder for a value, called a variable , which can be
plugged into a calculation over and over again. You have to do a little more work upfront to
set up a variable, but that effort pays off with faster calculations that are easier to read, edit,
and troubleshoot.
Search WWH ::




Custom Search