Hi, I'm Ask INFA!
What would you like to know?
ASK INFAPreview
Please to access Ask INFA.

Table of Contents

Search

  1. Preface
  2. Understanding Data Types and Field Properties
  3. Designing Processes
  4. Using and Displaying Data
  5. Designing Guides
  6. Designing Process Objects
  7. Designing Service Connectors
  8. Using App Connections
  9. System Services, Listeners and Connectors
  10. Designing Human Tasks

Design

Design

sum

sum

Returns a value obtained by adding together the values in
$arg
.

Syntax

fn:sum(arg, zero)
The following table describes the argument for this command:
Argument
Required/Optional
Description
arg
Required
Numeric data type. Passes the values you want to add. You can enter any valid transformation expression. You can use operators to add values in different fields.
zero
Required
The return condition for an empty sequence. If
$zero
is not specified, the value returned for an empty sequence is the
xs:integer
value 0. If
$zero
is specified, the value returned for an empty sequence is
$zero
.

Return Value

  • Numeric value.
  • NULL if all values passed to the function are NULL.
  • The
    $zero
    argument allows you to specify an alternate value for the sum of the empty sequence. If
    $arg
    is the empty sequence, and
    $zero
    is provided, the function returns
    $zero
    . The
    $zero
    argument could be the empty sequence, the integer 0, the value
    NaN
    , a duration of zero seconds, or any other atomic value.

Examples

The following table lists some sample values and return values:
SAMPLE FUNCTION
OUTPUT
fn:sum( (1, 2, 3) )
6
fn:sum( (1, 2, 3, () ) )
6
fn:sum( () )
0
fn:sum( (), () )
()
The following expression returns the sum of all values greater than 2000 in the Sales field:
sum( SALES, SALES > 2000 )
SALES
2500.0
1900.0
1200.0
NULL
3458.0
4519.0
RETURN VALUE:
10477.0

Tip

You can perform arithmetic on the values passed to sum before the function calculates the total. For example:
sum( QTY * PRICE - DISCOUNT )

0 COMMENTS

We’d like to hear from you!