You are here: Core Reference > Coding > Expressions > SUM

SUM

The SUM function is a mathematical function that returns the total value of a set of values. The total value is a real value.

Function Name

SUM

Description

Returns the sum total of a set of input values.

Arguments

SUM(INTEGER or REAL, INTEGER or REAL, INTEGER or REAL...)

Where each:

  • INTEGER or REAL is a numerical expression that defines a value in the set of values. The values have to be separated by a comma.

For more information on integers and real values, see Number (Integer or Real).

There is a SUM extension for use with Data Grids (see below).

Returns

REAL

The sum total of a set of values.

Example:

SUM(2, 3, 4, 1)

The output is 10.

SUM

Extension for Data Grids Only
The SUM function has been extended for use with Data Grids. It can support blocks of cells (arrays) as well as numerical values. This means that you can use fields and rows instead of numerical values in the SUM function (or you can use a combination of blocks, single cells and numbers as required).

Syntax

SUM(<Field1><Row1>, <Field2><Row1>, <Field3><Row1>...)

Where <Field1><Row1> is the name of a field in a row, <Field2><Row1> is the name of another field in the row and so on. Do not enter the angle brackets < >.

For blocks of cells, you have to define the first field and row and the last field and row in the range and separate them with a colon:

SUM(<FirstFieldinRange><FirstRowinRange>:<LastFieldinRange><LastRowinRange>)

NOTE: You can enter the last field first and the first field last if required, ClearSCADA will still recognize the required range.

Example:

SUM(A1:B9)

Where A1 defines the first cell to be used and B9 defines the last cell to be used. The SUM function will use the data from the cells between the A1 cell and the B9 cell in its calculation. If we assume that A1 is the first cell in a field named A and B9 is the 9th cell in a field named B, the SUM function will use the values from the cells in field A and the values from cells 1-9 inclusive from field B in its calculation.

SUM(A1:B9, 3, 75, C6, C8, D11)

Where A1:B9 defines a block of cells (the cells between the A1 cell and the B9 cell), 3 and 75 define numerical values, C6, C8, and D11 define individual cells. The SUM function will use the numerical values and the values from the defined cells (including the cells in the block) in its calculation.


ClearSCADA 2015 R2