SUM function
Synopsis
This function
returns the sum of the elements within an array. If the array is
empty, the function returns an error.
Variations
SUM(
SourceArray)
Returns the sum of all elements in
the source array.
Details |
Examples |
Details and examples
Parameters
SourceArray
Specifies the array to work with.
Supported types: Numeric array.
Returns
Examples
1. |
In the following example, the function calculates the sum of the
source array and returns 30.
SUM([10, 10,
10])
|
SUM(
SourceArray,
StartIndex,
Count)
Returns the sum of all the elements
in a subset of the source array.
Details |
Examples |
Details and examples
Parameters
SourceArray
Specifies the array to work with.
Supported types: Numeric array.
StartIndex
Specifies the beginning of the subset of the source array.
Supported types: Numeric.
Count
Specifies the number of elements to include in the subset of the
source array.
Supported types: Numeric.
Returns
Examples
1. |
In the following example, the function calculates the sum of the
specified subset of the source array and returns 80.
SUM([10, 10, 10,
10, 20, 20, 20, 20], 5, 4)
|
SUM(
SourceArray,
Expression)
Returns the sum of all elements in
the source array after performing an expression on each
element.
Details |
Examples |
Details and examples
Parameters
SourceArray
Specifies the array to work with.
Supported types: Numeric array; String
array; Boolean array; Point array; Object array.
Expression
Specifies the expression to apply to each element of the source
array.
Supported types: Numeric.
Returns
Examples
1. |
In the following example, the function calculates the sum of the
source array after performing the expression on each element,
returning 4.
SUM([10, 10, 10,
10], Item/10)
|
SUM(
SourceArray,
StartIndex,
Count,
Expression)
Returns the sum of all the elements
in a subset of the source array after performing an expression on
each element.
Details |
Examples |
Details and examples
Parameters
SourceArray
Specifies the array to work with.
Supported types: Numeric array; String
array; Boolean array; Point array; Object array.
StartIndex
Specifies the beginning of the subset of the source array.
Supported types: Numeric.
Count
Specifies the number of elements to include in the subset of the
source array.
Supported types: Numeric.
Expression
Specifies the expression to apply to each element of the source
array.
Supported types: Numeric.
Returns
Examples
1. |
In the following example, the function calculates the sum of the
specified subset of the source array, after performing the
expression on each element, returning 8.
SUM([10, 10, 10,
10, 20, 20, 20, 20], 5, 4, Item/10)
|