6.9.11 Totaling Expressions

It is possible to sum the changes that occur in an expression, not just the changes that occur in a field. For example, suppose that the invoice detail lines had a boolean field named taxable. If the line item was taxable, the taxable field would be true. If the line item was not taxable, the taxable field would be false. The subtotal of just the taxable detail lines can be calculated by using the calculation:

total (amount*taxable)

When the calculation is performed, the taxable field is converted to a number; 1 for true and 0 for false. Thus

amount*taxable

is zero for all nontaxable items and is the value of the amount field when the detail line is taxable.

This calculation will work whether adding, updating or deleting detail lines in the invoice and also works correctly when the taxable field is changed from true to false or vise versa.