ON THIS PAGE:
Format
TimeWeightedAverage_Sampled(Expr ,StartTime [,EndTime])
Returns
Returns the time-weighted average of the values of an expression over a range of time.
Inputs
Expr: The expression whose values should be averaged.
Behaviour: Required
Dimension: Collection
Valid data types: Boolean, Decimal, Integer
StartTime: The start time over which to produce the average.
Behaviour: Required
Dimension: Collection, SingleValue
Valid data types: DateTime, Decimal, Integer, String
EndTime: The end time over which to produce the average. If not specified, it assumes the current time.
Behaviour: Optional
Dimension: Collection, SingleValue
Valid data types: DateTime, Decimal, Integer, String
When to Use
A time-weighted average takes all the values that the expression held during a period of time, multiplies them by the time that the value was in effect, sums them, and then divides by the total time. This is most appropriate when producing averages of sampled continuous functions, such as the temperature of a furnace.
Examples
Expression: TimeWeightedAverage_Sampled(Expr, Time() - 60, Time())
Result: Average over the last minute (60 seconds).
Expression: TimeWeightedAverage_Sampled(Expr, Time() - 60)
Result: Average over the last minute (60 seconds).
Expression: TimeWeightedAverage_Sampled(Expr, Midnight(Time()))
Result: Average since midnight (the start of the day).
Expression: TimeWeightedAverage_Sampled({tag, sampleMethod = "Raw"}, Time() – 60)
Result: Average of the raw values over the last minute.
Expression: TimeWeightedAverage_Sampled(Sampling(Expr, "raw"), Time() - 60)
Result: Average of the raw values over the last minute.