Format
Sum(Number [,Numbers])
Returns
Returns the sum of values per timestamp.
Inputs
Number: The argument whose values should be summed.
Behaviour: Required
Dimensions: Collection, SingleValue
Valid data types: Decimal, Integer
Numbers: Additional arguments whose values should be summed.
Behaviour: Optional [0..n]
Dimensions: Collection, SingleValue
Valid data types: Decimal, Integer
Error Conditions
An error will be thrown if:
- A tag or entity supplied as an argument does not exist.
- The data type of a parameter is not valid.
- One of the inputs contains a Data Dictionary function (e.g. DDGet) - this may occur if a calculation tag is used, and the calculation contains a DD function.
- Error: Parameter no. 1 of function 'Sum' must not be a 'multi-collection' variable (typically Data Dictionary functions return such values).
Examples
Expression: Sum(1,2)
Result: Returns 3.
Expression: Sum(1,2,1)
Result: Returns 4.
Expression: Sum({Tag1}, {Tag2})
Result: Returns the sum of values for each timestamp.
Expression: Sum({Abes.GasActual},{Anstey.GasActual},{Archer.GasActual})
Returns: The total Gas Actual for Abes, Anstey, and Archer.
Result: 11584
Related Functions
The following table illustrates the difference between the Sum(), DDSum(), and Sum_Sampled() functions. The following calculations were used to sum a row (Sum_Sampled) or column (Sum and DDSum):
Total Daily Oil Production for all online wells:
DDSum(DDGet("Hierarchy", 2, "Field1", ":Oil Production", "{[Well]:Status} == 'Online'", "Well"))
Sum({Well 1:Oil Production},{Well 2:Oil Production})
Sum({Well 1:Oil Production},{Well 2:Oil Production},{Well 3:Oil Production})
Total Weekly Oil Production for a well:
Sum_Sampled({Well 1:Oil Production},"Monday","Friday")
Sum_Sampled({Well 2:Oil Production},"Monday","Friday")
Sum_Sampled({Well 3:Oil Production},"Tuesday","Friday")
In this example, Well 3 did not exist before Tuesday, and the Sum() and Sum_Sampled() calculations will throw an error if an entity does not exist.
Entity/Attributes | Timestamps | ||||||||
Monday** | Tuesday | Wednesday | Thursday | Friday | Total Weekly Oil Production Using Sum_Sampled()^ | Calc Used: | |||
Field 1 | Well 1 | Production (bbl): | 1 | 3 | 2 | 4 | 2 | 12 | Sum_Sampled({Well 1:Oil Production},"Monday","Friday") |
Status: | Online | Offline | Online | Online | Online | ||||
Well 2 | Production (bbl): | 2 | 1 | 1 | 3 | 2 | 9 | Sum_Sampled({Well 2:Oil Production},"Monday","Friday") | |
Status: | Online | Online | Offline | Online | Online | ||||
Well 3* | Production (bbl): | DID NOT EXIST | 2 | 1 | 2 | 2 | 7* | Sum_Sampled({Well 3:Oil Production},"Tuesday","Friday") | |
Status: | Online | Online | Offline | Online | |||||
Total Daily Oil Production Using Sum() | 3** | 6 | 4 | 9 | 6 | ||||
Sum({Well 1:Oil Production},{Well 2:Oil Production}) | Sum({Well 1:Oil Production},{Well 2:Oil Production},{Well 3:Oil Production}) | Sum({Well 1:Oil Production},{Well 2:Oil Production},{Well 3:Oil Production}) | Sum({Well 1:Oil Production},{Well 2:Oil Production},{Well 3:Oil Production}) | Sum({Well 1:Oil Production},{Well 2:Oil Production},{Well 3:Oil Production}) | |||||
Total Daily Oil Production Using DDSum()^ DDSum(DDGet("Hierarchy", 2, "Field1", ":Oil Production", "{[Well]:Status} == 'Online'", "Well")) |
Error: Well 3:Status doesn't exist | 3 | 3 | 7 | 6 |
Notes:
* For Well 3, the Sum_Sampled() calculation should not include Monday, because it did not exist then. It will throw an error if you try to evaluate Well 3 starting from Monday, but will return a value if you evaluate it from Tuesday.
** On Monday, the Sum() calculation should not include Well 3, because it did not exist then and will throw an error. Well 3 can only be included in the calculation from Tuesday onwards.
^ For an explanation of how the values for DDSum() and Sum_Sampled() are calculated, refer to their respective pages.