These docs are for v1.0. Click to read the latest docs for v1.2.

REDUCE

Returns a value resulting from applying a formula to each element of the array and the previous result.

Syntax

=REDUCE(initialValue, array, expression)

Arguments

ArgumentTypeDescription
initialValueAnyInitial value for the previous result
arrayArrayArray of elements
expressionLambdaTransformation to perform on each item of the array

Examples

=REDUCE(0, [10, 20, 30], x => x + x.previous)60
REDUCE function is called for each item in the array (the values 10, 20, and 30). For each item, the value is added to the previous result. The last result is returned for the function, resulting in the value 60.