RangeSum - script and chart function
Syntax:
RangeSum(first_expr[, Expression])
Return data type: numeric
Arguments:
The argument of this function may contain inter-record functions which in themselves return a list of values.
Argument | Description |
---|---|
|
The expression or field containing the data to be summed. |
|
Optional expressions or fields containing additional data to be summed. Multiple additional expressions can be used. |
Limitations:
The RangeSum function treats all non-numeric values as 0, unlike the + operator.
Examples and results:
Examples | Results | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
RangeSum (1,2,4) |
Returns 7 |
||||||||||||||||
RangeSum (5,'abc') | Returns 5 | ||||||||||||||||
RangeSum (null( )) |
Returns 0 |
||||||||||||||||
Add the example script to your document and run it. Then add, at least, the fields listed in the results column to a sheet in your document to see the result. RangeTab3: LOAD recno() as RangeID, Rangesum(Field1,Field2,Field3) as MyRangeSum INLINE [ Field1, Field2, Field3 10,5,6 2,3,7 8,2,8 18,11,9 5,5,9 9,4,2 ]; |
|
Example with expression:
RangeSum (Above(MyField,0,3))
Returns the sum of the
three values of MyField): from
the current row and two rows above the current row. By specifying the third argument as
Data used in examples:
MyField | RangeSum(Above(MyField,0,3)) |
---|---|
10 | 10 |
2 |
12 |
8 | 20 |
18 | 28 |
5 | 31 |
9 | 32 |
Data used in examples:
RangeTab:
LOAD * INLINE [
MyField
10
2
8
18
5
9
] ;