Skip to end of metadata
Go to start of metadata

This function is used in Python Scripting.


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.


This function accepts keyword arguments.

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

  • Parameters

PySequence paths - An 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.

PySequence calculations - An 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".

 Date startDate - The starting point for the calculation window. If omitted, and range is not used, 8 hours before the current time is used.

 Date endDate - The end of the calculation window. If omitted, and range is not used, uses the current time.

 Integer rangeHours - Allows 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.

 Integer rangeMinutes - Same as rangeHours, but in minutes.

 PySequence aliases - Aliases 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.

 Boolean includeBoundingValues - A 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".

 Boolean validatesSCExec - A 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"

 Boolean noInterpolation - A 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"

 Boolean ignoreBadQuality - A 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


Code Examples
Code Snippet
 system.tag.queryTagCalculations(paths=['Historical Tag'], calculations=['Average'], noInterpolation=False)
  • No labels


  1. Anonymous

    "SimipleAverage" does not work as a Calculation keyword.

    WARN: Traceback (most recent call last):
    File "<function:updateData>", line 46, in updateData
    TypeError: Aggregation mode "null" does not exist.

    1. Thanks for letting us know about the typo!

  2. Anonymous

    It is just a typo in the reference above.