Skip to main content
Version: 7.9

system.tag.queryTagCalculations

This function is used in Python Scripting.

Description

Queries various calculations (aggregations) for a set of tags over a specified range. Returns a dataset with a row per tag, and a column per calculation.

This is useful when you wish to aggregate tag history collected over a period of time into a single value per aggregate. If you want multiple values aggregated to a single time slice (i.e., hourly aggregates for the same tag over an 8 hour period) consider using system.tag.queryTagHistory.

Client Permission Restrictions

This scripting function has no Client Permission restrictions.

Syntax

tip

This function accepts keyword arguments.

system.tag.queryTagCalculations(paths, calculations, startDate, endDate, rangeHours, rangeMinutes, aliases, includeBoundingValues, validatesSCExec, noInterpolation, ignoreBadQuality)

Parameters

TypeParameterDescription
PySequencepathsAn array of tag paths (strings) to query calculations for. The resulting dataset will have a row for each tag, and a column for each calculation.
PySequencecalculationsAn array of calculations (aggregation functions) to execute for each tag. Valid values are: "Average" (time-weighted), "MinMax", "LastValue", "SimpleAverage", "Sum", "Minimum", "Maximum", "DurationOn", "DurationOff", "CountOn", "CountOff", "Count", "Range", "Variance", "StdDev", "PctGood", and "PctBad".
DatestartDateThe starting point for the calculation window. If omitted, and range is not used, 8 hours before the current time is used.
DateendDateThe end of the calculation window. If omitted, and range is not used, uses the current time.
IntegerrangeHoursAllows you to specify the query range in hours, instead of using start and end date. Can be positive or negative, and can be used in conjunction with startDate or endDate.
IntegerrangeMinutesSame as rangeHours, but in minutes.
PySequencealiasesAliases that will be used to override the tag path names in the result dataset. Must be 1-to-1 with the tag paths. If not specified, the tag paths themselves will be used.
BooleanincludeBoundingValuesA boolean flag indicating that the system should attempt to load values before and after the query bounds for the purpose of interpolation. The effect depends on the aggregates used. The default is "true". See Seeded Values for more information.
BooleanvalidatesSCExecA boolean flag indicating whether or not data should be validated against the scan class execution records. If false, calculations may include data that is assumed to be good, even though the system may not have been running. Default is "true".
BooleannoInterpolationA boolean flag indicating that the system should not attempt to interpolate values in situations where it normally would, such as for analog tags. Default is "false".
BooleanignoreBadQualityA boolean flag indicating that bad quality values should not be used in the query process. If set, any value with a "bad" quality will be completely ignored in calculations. Default is "false".

Returns

Dataset - A dataset representing the calculations over the specified range. There is a row per tag id, and a column per requested calculation. Tag path is returned in the first column.

Scope

All

Code Examples

Example #1
system.tag.queryTagCalculations(paths=['Historical Tag'], calculations=['Average'], noInterpolation=False)