Total
- Last UpdatedJan 11, 2023
- 2 minute read
- PI System
- PI Server 2018
- PI Server
Return the time-weighted or event-weighted sum of two or more values.
Syntax
Total(x1, x2 [, ... xn])
Total(array [, calculationBasis])
Arguments
-
x1, ... xn
Numbers, time intervals or a single array of numbers or time intervals
-
calculationBasis
Optional. The type of calculation to be performed enclosed in double quotes. Choose between "EventWeighted" or "TimeWeighted." If omitted, the default is event-weighted. If you select "TimeWeighted," the earliest timestamp of the value marks the start time and the latest timestamp the end of a time range
Returns
The total of the arguments. The result has the same data type as the arguments
Exceptions
Arguments whose run-time values are digital states are not included in the total. If all values are digital states, Total returns an error value. Returns an error if the array does not consist of same value type
Notes
-
Unit of Measure (UOM) of the arguments is carried over to the result when at least one argument has a defined UOM while others don't. The returned value lacks a UOM if arguments have different UOMs
Example
-
Total('att1', 'att2', TagVal('att1', 'y+2h'), 40)
[Return the sum of following values: values of 'att1' and 'att2' at current time, the value of 'att1' at 2am yesterday and 40]
-
Total('t'-'y', '+1h')
[Returns 1.01:00:00]
-
Total(Variable1)
Name
Expression
Value at Evaluation
Variable1
RecordedValues('att1', '*-10m', '*')
[1, 3, 5, 7, 9]
Variable 2
Total(Variable1)
25
[Return the sum of values in an array named Variable1]
-
Total(Data)
[Return the event-weighted sum of values from an array named Data]
-
Total(Data, "EventWeighted")
[Return the event-weighted sum of values from an array named Data]
-
Total(Data, "TimeWeighted")
[Return the time-weighted sum of values from an array named Data using the timestamps of the earliest and latest values of the array as the start time and end time respectively]