Can you make a Query tag that queries a tag in Tag History? How?

I am using tag history bindings. Through a flex repeater(30 instances) to evaluate Duration On of a bool Expression tag(“Producing”). That is an expression of several OPC tags. That eventually compares against seconds in a shift or day.

Works great. But, consumes a ton of resources. When it polls.

I need to get a query tag that provides me a scalar value of Duration On of this “Producing” tag.

But I don’t know how to query the historian manually. Should it be a query tag or tag change script using system.tag.queryTagHistory - Ignition User Manual 8.0 - Ignition Documentation or what?

  "type": "tag-history",
  "config": {
    "dateRange": {
      "startDate": "{[default]SCADA/Time/shift.Timestamp}",
      "endDate": "now(30000)"
    "calculations": [
    "tags": "{view.custom.hist}",
    "returnFormat": "Calculations",
    "valueFormat": "DOCUMENT",
    "ignoreBadQuality": false,
    "preventInterpolation": false,
    "avoidScanClassValidation": true

view.custom.hist :point_down:

    "aggregate": "DurationOn",
    "alias": "ava",
    "path": "[default]D06/D06/Status/Producing"

Any guidance on how to wrap this all up in a tag to provide an int of seconds of duration on for [default]D06/D06/Status/Producing. So all the instances can just read a tag. Instead of individually querying

Would be much appreciated.

For something similar I’m using system.tag.queryTagCalculations(). I have to return a count and duration on for multiple tags though, the line I’m using for it is,modified by what I see above:

pathIn = ["[default]D06/D06/Status/Producing"]
start ='[default]SCADA/Time/shift').timestamp
end =
hist = system.tag.queryTagCalculations(paths=pathIn,calculations=['DurationOn'],startDate=start,endDate=end,ignoreBadQuality=1,includeBoundingValues=0)

I’m running this in a gateway timer script so it doesn’t put the load on the UI. Then in my script I’m breaking it up into the individual values and feeding them into memory tags to use on the screen.

1 Like