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:
For more information on integers and real values, see Number (Integer or Real). There are SUM extensions for use with Data Grids and Data Sets (see below). |
Returns |
REAL The sum total of a set of values. |
Example:
SUM(2, 3, 4, 1)
The output is 10.
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 of cells, 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>)
You can enter the last field first and the first field last if required, ClearSCADA will still recognize the required range.
Examples when used with Data Grids:
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, and including, the A1 cell and the B9 cell in its calculation. If we assume that A1 is the 1st 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 (comprising the cells between, and including, 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.
The SUM function has been extended for use with Data Sets. It can support blocks of fields (arrays) as well as numerical values. This means that you can use fields instead of numerical values in the SUM function (or you can use a combination of blocks of fields, single fields and numbers as required).
Syntax
SUM(<Field1>, <Field2>, <Field3>...)
Where <Field1>
is the name of a field in a Data Set Row, <Field2>
is the name of another field in the Data Set Row, and so on. Do not enter the angle brackets < >.
For blocks of fields, you have to define the first field and the last field in the range and separate them with a colon:
SUM(<FirstFieldinRange>:<LastFieldinRange>)
You can enter the last field first and the first field last if required, ClearSCADA will still recognize the required range.
Examples when used with Data Sets:
SUM(A:H)
Where A defines the first field to be used and H defines the last field to be used in a block of fields. The SUM function will use the data from the fields between, and including, the fields A to H in its calculation. If we assume that A is the 1st field in a block of fields and H is the 8th field in that block of fields, the SUM function will use the values from fields 1-8 inclusive in its calculation.
SUM(A:H, 3, 75, R, K, P)
Where A:H defines a block of fields (comprising the fields between, and including, the fields A to H), 3 and 75 define numerical values, R, K, and P define individual fields. The SUM function will use the numerical values and the values from the defined fields (including the fields in the block) in its calculation.