Multiple aggregation over a period of time

Hello folks,

I have 2 counters.

  • TotalEvent
  • BadEvents

These couters are in the PLC and never reset. The counters are collected trought the historian.

As an example, I’d like to enter a date range (example last 7 days) and get the differences of the counters values per period of 24 hours beggining at 7:30 in the morning.

Then using a script, I will calculate the bad percentage per period of 24 hours for the last 7 days.

I’m strugguling with the query to the historian…

Can someone help me?
Thanks.

Use system.tag.queryTagHistory. Set the startDate and endDate according to your selected date range. Set the intervalHours to 24, and the aggregation to Range.

Include both tags in the paths list and the dataset will return the range over each 24hour period within the given date range.

The logic may not reset them but at some point they will roll over. You should account for this in the script.

1 Like