Skip to main content
Version: 8.1

Tag Calculation Query

Inductive University

Tag Calculation Query

Watch the video

Tag Calculations are executed by the Tag Historian, providing multiple calculated values for each Tag path. While the Tag Historian Query returns a history of values and only uses the aggregates to perform calculations on small chunks of data in the range of time, the Tag Calculation Query will aggregate, or run calculations, on the entire range to produce a single, calculated value per Tag Path.

Assuming the following configuration:

We could show the query results on a table and view the following in the Preview Panel:

AverageSumTag PathTimestamp
0.281601.21sine0Mar 10, 2020
165.561260330.57sine1Mar 10, 2020
1.076024.47sine2Mar 10, 2020

Tag Historian vs Tag Calculation​

When deciding between a Tag Calculation Query and a Tag Historian Query, the main difference between the two is as follows:

  • The Tag Calculation Query will always return a single row for each Tag Path, with multiple columns for each aggregate/calculation, except in the case of Min/Max (see below).
  • Multiple calculations may be called on each Tag Path. This is not possible with a single Tag Historian Query.

The 'Min/Max' Exception​

Since Min/Max returns two values (the minimum and maximum value over the range), this calculation will generate two rows per Tag Path. This extra row will appear in the underlying data, even if the MinMax key isn't used in a table or chart, as it is part of the underlying data.

If we added Min/Max to our example above, the preview panel would look like the following:

AverageSumTag PathTimestampMinMax
0.09351.01sine0Mar 10, 2020-50
165.711224266.37sine1Mar 10, 2020321
0.12379.52sine2Mar 10, 2020100
0.09351.01sine0Mar 10, 202050
165.711224266.37sine1Mar 10, 202010
0.12379.52sine2Mar 10, 2020-100
note

The other calculations (Average and Sum) are simply duplicated for both MinMax rows.