ON THIS PAGE:
Format
Average_Sampled(Expr ,StartTime [,EndTime])
Returns
Returns the 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, Duration, Integer
StartTime: The start time over which to produce the average. You can use the Time() function to use a valid DateTime argument.
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. You can use the Time() function to use a valid DateTime argument.
Behaviour: Optional
Dimension: Collection, SingleValue
Valid data types: DateTime, Decimal, Integer, String
When to Use
This is a sample-based average, that is, it sums all of the values in the time range, and then divides by the total number of samples. This is most appropriate when producing averages of a batch-based quantity, such as the moisture content of coal shipments.
Examples
Expression: Average_Sampled(Expr, Time() - 60, Time())
Result: Average over the last minute (60 seconds).
Expression: Average_Sampled(Expr, Time() - 60)
Result: Average over the last minute (60 seconds).
Expression: Average_Sampled(Expr, Midnight(Time()))
Result: Average since midnight (the start of the day).
Expression: Average_Sampled({tag, sampleMethod = "Raw"}, Time() – 60)
Result: Average of the raw values over the last minute.
Expression: Average_Sampled(Sampling(Expr, "raw"), Time() - 60)
Result: Average of the raw values over the last minute.