Reference > Functions reference > Aggregate functions > Sum
 

Sum

Returns the total of all valid, non-blank values in a field.

Format 

Sum(field{;field...})

Parameters 

field - any related field, repeating field, or set of non-repeating fields; or an expression that returns a field, repeating field, or set of non-repeating fields.

Parameters in braces { } are optional.

Data type returned 

number

Originated in 

FileMaker Pro 6.0 or earlier

Description 

Field can be any of the following:

a repeating field (repeatingField).

a field in matching related records specified by (table::field), whether or not these records appear in a portal.

several non-repeating fields in a record (field1;field2;field3...).

corresponding repetitions of repeating fields in a record (repeatingField1;repeatingField2;repeatingField3), if the result is returned in a repeating field with at least the same number of repeats.

several fields in the first matching record specified by (table::field1;table::field2;...). You can include fields from different tables (table 1::field A;table 2::field B...).

Notes 

When a referenced field is a repeating field, the Sum function returns the sum of the first repetition field, then the sum of the second repetition field, and so on.

Example 1 

An Invoice table has a portal showing line items.

Sum(LineItems::ExtendedPrice) totals the amounts for all items on the invoice.

Example 2 

A TimeBilling table has a portal showing time worked on a project. Hours is a time field.

Sum(Hours::BillableHours) returns the total number of billable hours on a project. Thus, if the portal shows 40 hours and 15:30 hours, the total billable hours are 55:30, or 55 1/2 hours.

Example 3 

In the following examples:

Field1 contains two repetitions with values of 1 and 2.

Field2 contains four repetitions with values of 5, 6, 7, and 8.

Field3 contains 6.

If the calculation result isn’t a repeating field:

Sum(Field2) returns 26.

Sum(Field1;Field2;Field3) returns 12.

If the calculation result is a repeating field:

Sum(Field2) returns a repeating field with 26 in the first repetition.

Sum(Field1;Field2;Field3) returns a repeating field with 12, 8, 7, 8.

Related topics 

Functions reference (category list)

Functions reference (alphabetical list)

About formulas

About functions

Defining calculation fields

Using operators in formulas