TagMean
- Last UpdatedJan 11, 2023
- 2 minute read
- PI System
- PI Server 2018
- PI Server
Find the average (mean) of values for an attribute during a specified time range. TagAvg with event-weighted option provides the same result as TagMean. Consider using TagAvg rather than TagMean especially if time-weighted TagAvg is used in other analyses.
Syntax
TagMean(attname, starttime, endtime [, pctgood])
Arguments
-
attname
attribute with time series data (such as PI point data reference) enclosed in single quotes
-
starttime
time expression representing the beginning of a time range enclosed in single quotes; can be a relative time (such as'-3h') in reference to an absolute endtime
-
endtime
time expression representing the end of a time range enclosed in single quotes; can be a relative time (such as '+1h') in reference to an absolute starttime
-
pctgood
Optional: Minimum percentage of the specified time range that attribute values must be good.
Returns
The attribute's average value over the given time. Notice that the average is not time-weighted. For time-weighted average, use TagAvg instead
Exceptions
If the attribute has no good values or the pctgood minimum is not reached for the specified time range, an error value is returned. Unlike some other summary functions, TagMean does not interpolate any value on the boundary. Thus, if there is no value in the specified interval, an error value is returned
Notes
Bad values are excluded from TagMean calculation
Note: If the attribute has very few good values during the time range, this function's result may not be trustworthy. Use the PctGood function to find out what percentage of the values is good
Example
-
TagMean('att1', 't', '+1h')
[Return the average (mean) value of 'att1' between 12:00 and 1:00am today]
-
TagMean('att1', 't', '+1h', 80)
[Return the average (mean) value of 'att1' between 12:00 and 1:00am today when at least 80% of the values were good]
-
TagMean('att1', '14-Dec-16', '15-Dec-16')
[Return the average (mean) value of 'att1' between 12:00am 12/14/2016 and 12:00am 12/15/2016]