@Sum (Formula Language)

Adds a set of numbers or number lists.

Syntax

@Sum( numbers )

Parameters

numbers

Numbers or number lists. As many numbers or number lists as you want to sum.

Return value

result

Number. The sum of all the numbers, including members of number lists.

Usage

Make sure the fields you send as parameters contain a number value -- Notes/Domino interprets empty number fields as the null string.

Since list concatenation has the highest precedence, list elements that are expressions must be in parentheses if the expression applies only to that element. For example, write @Sum(1:2:(-3):4), not @Sum(1:2:-3:4), if 3 is negative and 4 is not.

Examples

  1. This example returns 3.
    @Sum( 1 : 2 )
  2. This example returns 11.
    @Sum( (-1) : 2 ; (-10) : 20 )
  3. This example sets the Total field to 50 if numPersons is a number field containing 5; 10; 15; 20.
    @SetField("Total";@Sum(numPersons))
  4. This example looks at the Transactions view in the current database, whose first column contains number values indicating the amount of a transaction. The formula sums the transactions and places the total in the result field on the current document.
    FIELD result:=result;
    r:=@DbColumn("":""; ""; "Transactions"; 1 );
    @SetField( "result"; @Sum( r ) )
  5. This example displays a view in a dialog box. The first column in the view contains a product name, the second contains its price. After the user selects one or more products in the dialog box, the formula displays the total cost of the selected items.
    amounts:=@PickList( [Custom]; @DbName ; "Products"; "Choose products"; "Please select the products you want to order"; 2 );
    total:=@Sum( @TextToNumber( amounts ) );
    @Prompt([Ok]; "Total"; "The total cost of these products is " + @Text(total))