I’m trying to use tag history binding to calculate a tag’s time weighted average. (The tag is a discrete). And I’m getting some unexpected behaviors.
1st example,
This is the dataset from “as-stored” binding:
And this is my binding for the average calculation.
And this is what’s returned with the average calc in 1 hour intervals:
"#NAMES"
"t_stamp","d32c compressor_3"
"#TYPES"
"date","D"
"#ROWS","240"
"2025-12-28 00:00:00.000","1.0"
"2025-12-28 01:00:00.000","1.0"
"2025-12-28 02:00:00.000","1.0"
"2025-12-28 03:00:00.000","1.0"
"2025-12-28 04:00:00.000","1.0"
"2025-12-28 05:00:00.000","1.0"
"2025-12-28 06:00:00.000","1.0"
"2025-12-28 07:00:00.000","1.0"
"2025-12-28 08:00:00.000","1.0"
"2025-12-28 09:00:00.000","1.0"
"2025-12-28 10:00:00.000","1.0"
"2025-12-28 11:00:00.000","1.0"
"2025-12-28 12:00:00.000","1.0"
"2025-12-28 13:00:00.000","1.0"
"2025-12-28 14:00:00.000","1.0"
"2025-12-28 15:00:00.000","1.0"
"2025-12-28 16:00:00.000","1.0"
"2025-12-28 17:00:00.000","1.0"
"2025-12-28 18:00:00.000","1.0"
"2025-12-28 19:00:00.000","1.0"
"2025-12-28 20:00:00.000","1.0"
"2025-12-28 21:00:00.000","1.0"
"2025-12-28 22:00:00.000","1.0"
"2025-12-28 23:00:00.000","1.0"
"2025-12-29 00:00:00.000","1.0"
"2025-12-29 01:00:00.000","1.0"
"2025-12-29 02:00:00.000","1.0"
"2025-12-29 03:00:00.000","1.0"
"2025-12-29 04:00:00.000","1.0"
"2025-12-29 05:00:00.000","1.0"
"2025-12-29 06:00:00.000","1.0"
"2025-12-29 07:00:00.000","1.0"
"2025-12-29 08:00:00.000","1.0"
"2025-12-29 09:00:00.000","1.0"
"2025-12-29 10:00:00.000","1.0"
"2025-12-29 11:00:00.000","1.0"
"2025-12-29 12:00:00.000","1.0"
"2025-12-29 13:00:00.000","1.0"
"2025-12-29 14:00:00.000","1.0"
"2025-12-29 15:00:00.000","1.0"
"2025-12-29 16:00:00.000","1.0"
"2025-12-29 17:00:00.000","1.0"
"2025-12-29 18:00:00.000","1.0"
"2025-12-29 19:00:00.000","1.0"
"2025-12-29 20:00:00.000","1.0"
"2025-12-29 21:00:00.000","1.0"
"2025-12-29 22:00:00.000","1.0"
"2025-12-29 23:00:00.000","1.0"
"2025-12-30 00:00:00.000","1.0"
"2025-12-30 01:00:00.000","1.0"
"2025-12-30 02:00:00.000","1.0"
"2025-12-30 03:00:00.000","1.0"
"2025-12-30 04:00:00.000","1.0"
"2025-12-30 05:00:00.000","1.0"
"2025-12-30 06:00:00.000","1.0"
"2025-12-30 07:00:00.000","1.0"
"2025-12-30 08:00:00.000","1.0"
"2025-12-30 09:00:00.000","0.4534780426327896"
"2025-12-30 10:00:00.000","0.0"
"2025-12-30 11:00:00.000","0.6131886425524007"
"2025-12-30 12:00:00.000","1.0"
"2025-12-30 13:00:00.000","1.0"
"2025-12-30 14:00:00.000","1.0"
"2025-12-30 15:00:00.000","1.0"
"2025-12-30 16:00:00.000","1.0"
"2025-12-30 17:00:00.000","1.0"
"2025-12-30 18:00:00.000","1.0"
"2025-12-30 19:00:00.000","1.0"
"2025-12-30 20:00:00.000","1.0"
"2025-12-30 21:00:00.000","1.0"
"2025-12-30 22:00:00.000","1.0"
"2025-12-30 23:00:00.000","1.0"
"2025-12-31 00:00:00.000","1.0"
"2025-12-31 01:00:00.000","1.0"
"2025-12-31 02:00:00.000","1.0"
"2025-12-31 03:00:00.000","1.0"
"2025-12-31 04:00:00.000","1.0"
"2025-12-31 05:00:00.000","1.0"
"2025-12-31 06:00:00.000","1.0"
"2025-12-31 07:00:00.000","1.0"
"2025-12-31 08:00:00.000","1.0"
"2025-12-31 09:00:00.000","1.0"
"2025-12-31 10:00:00.000","1.0"
"2025-12-31 11:00:00.000","1.0"
"2025-12-31 12:00:00.000","1.0"
"2025-12-31 13:00:00.000","1.0"
"2025-12-31 14:00:00.000","1.0"
"2025-12-31 15:00:00.000","1.0"
"2025-12-31 16:00:00.000","1.0"
"2025-12-31 17:00:00.000","1.0"
"2025-12-31 18:00:00.000","1.0"
"2025-12-31 19:00:00.000","1.0"
"2025-12-31 20:00:00.000","1.0"
"2025-12-31 21:00:00.000","1.0"
"2025-12-31 22:00:00.000","1.0"
"2025-12-31 23:00:00.000","1.0"
"2026-01-01 00:00:00.000","1.0"
"2026-01-01 01:00:00.000","1.0"
"2026-01-01 02:00:00.000","1.0"
"2026-01-01 03:00:00.000","1.0"
"2026-01-01 04:00:00.000","1.0"
"2026-01-01 05:00:00.000","1.0"
"2026-01-01 06:00:00.000","1.0"
"2026-01-01 07:00:00.000","1.0"
"2026-01-01 08:00:00.000","1.0"
"2026-01-01 09:00:00.000","1.0"
"2026-01-01 10:00:00.000","1.0"
"2026-01-01 11:00:00.000","1.0"
"2026-01-01 12:00:00.000","1.0"
"2026-01-01 13:00:00.000","1.0"
"2026-01-01 14:00:00.000","1.0"
"2026-01-01 15:00:00.000","1.0"
"2026-01-01 16:00:00.000","1.0"
"2026-01-01 17:00:00.000","1.0"
"2026-01-01 18:00:00.000","1.0"
"2026-01-01 19:00:00.000","1.0"
"2026-01-01 20:00:00.000","1.0"
"2026-01-01 21:00:00.000","1.0"
"2026-01-01 22:00:00.000","1.0"
"2026-01-01 23:00:00.000","1.0"
"2026-01-02 00:00:00.000","1.0"
"2026-01-02 01:00:00.000","1.0"
"2026-01-02 02:00:00.000","1.0"
"2026-01-02 03:00:00.000","1.0"
"2026-01-02 04:00:00.000","1.0"
"2026-01-02 05:00:00.000","1.0"
"2026-01-02 06:00:00.000","1.0"
"2026-01-02 07:00:00.000","1.0"
"2026-01-02 08:00:00.000","1.0"
"2026-01-02 09:00:00.000","1.0"
"2026-01-02 10:00:00.000","1.0"
"2026-01-02 11:00:00.000","1.0"
"2026-01-02 12:00:00.000","1.0"
"2026-01-02 13:00:00.000","1.0"
"2026-01-02 14:00:00.000","1.0"
"2026-01-02 15:00:00.000","1.0"
"2026-01-02 16:00:00.000","1.0"
"2026-01-02 17:00:00.000","1.0"
"2026-01-02 18:00:00.000","1.0"
"2026-01-02 19:00:00.000","1.0"
"2026-01-02 20:00:00.000","1.0"
"2026-01-02 21:00:00.000","1.0"
"2026-01-02 22:00:00.000","1.0"
"2026-01-02 23:00:00.000","1.0"
"2026-01-03 00:00:00.000","1.0"
"2026-01-03 01:00:00.000","1.0"
"2026-01-03 02:00:00.000","1.0"
"2026-01-03 03:00:00.000","1.0"
"2026-01-03 04:00:00.000","1.0"
"2026-01-03 05:00:00.000","1.0"
"2026-01-03 06:00:00.000","1.0"
"2026-01-03 07:00:00.000","1.0"
"2026-01-03 08:00:00.000","1.0"
"2026-01-03 09:00:00.000","1.0"
"2026-01-03 10:00:00.000","1.0"
"2026-01-03 11:00:00.000","1.0"
"2026-01-03 12:00:00.000","1.0"
"2026-01-03 13:00:00.000","1.0"
"2026-01-03 14:00:00.000","1.0"
"2026-01-03 15:00:00.000","1.0"
"2026-01-03 16:00:00.000","1.0"
"2026-01-03 17:00:00.000","1.0"
"2026-01-03 18:00:00.000","1.0"
"2026-01-03 19:00:00.000","1.0"
"2026-01-03 20:00:00.000","1.0"
"2026-01-03 21:00:00.000","1.0"
"2026-01-03 22:00:00.000","1.0"
"2026-01-03 23:00:00.000","1.0"
"2026-01-04 00:00:00.000","1.0"
"2026-01-04 01:00:00.000","1.0"
"2026-01-04 02:00:00.000","1.0"
"2026-01-04 03:00:00.000","1.0"
"2026-01-04 04:00:00.000","1.0"
"2026-01-04 05:00:00.000","1.0"
"2026-01-04 06:00:00.000","1.0"
"2026-01-04 07:00:00.000","1.0"
"2026-01-04 08:00:00.000","1.0"
"2026-01-04 09:00:00.000","1.0"
"2026-01-04 10:00:00.000","1.0"
"2026-01-04 11:00:00.000","1.0"
"2026-01-04 12:00:00.000","1.0"
"2026-01-04 13:00:00.000","0.2868113296698138"
"2026-01-04 14:00:00.000","0.0"
"2026-01-04 15:00:00.000","0.0"
"2026-01-04 16:00:00.000","0.0"
"2026-01-04 17:00:00.000","0.0"
"2026-01-04 18:00:00.000","0.0"
"2026-01-04 19:00:00.000","0.0"
"2026-01-04 20:00:00.000","0.0"
"2026-01-04 21:00:00.000","0.0"
"2026-01-04 22:00:00.000","0.0"
"2026-01-04 23:00:00.000","0.0"
"2026-01-05 00:00:00.000","0.0"
"2026-01-05 01:00:00.000","0.0"
"2026-01-05 02:00:00.000","0.0"
"2026-01-05 03:00:00.000","0.0"
"2026-01-05 04:00:00.000","0.0"
"2026-01-05 05:00:00.000","0.0"
"2026-01-05 06:00:00.000","0.0"
"2026-01-05 07:00:00.000","0.0"
"2026-01-05 08:00:00.000","0.0"
"2026-01-05 09:00:00.000","0.0"
"2026-01-05 10:00:00.000","0.0"
"2026-01-05 11:00:00.000","0.0"
"2026-01-05 12:00:00.000","0.0"
"2026-01-05 13:00:00.000","0.0"
"2026-01-05 14:00:00.000","0.0"
"2026-01-05 15:00:00.000","0.03348764819101339"
"2026-01-05 16:00:00.000","1.0"
"2026-01-05 17:00:00.000","1.0"
"2026-01-05 18:00:00.000","1.0"
"2026-01-05 19:00:00.000","1.0"
"2026-01-05 20:00:00.000","1.0"
"2026-01-05 21:00:00.000","1.0"
"2026-01-05 22:00:00.000","1.0"
"2026-01-05 23:00:00.000","1.0"
"2026-01-06 00:00:00.000","1.0"
"2026-01-06 01:00:00.000","1.0"
"2026-01-06 02:00:00.000","1.0"
"2026-01-06 03:00:00.000","1.0"
"2026-01-06 04:00:00.000","1.0"
"2026-01-06 05:00:00.000","1.0"
"2026-01-06 06:00:00.000","1.0"
"2026-01-06 07:00:00.000","1.0"
"2026-01-06 08:00:00.000","0.233178814771893"
"2026-01-06 09:00:00.000","0.0"
"2026-01-06 10:00:00.000","0.0"
"2026-01-06 11:00:00.000","0.0"
"2026-01-06 12:00:00.000","0.0"
"2026-01-06 13:00:00.000","0.0"
"2026-01-06 14:00:00.000","0.0"
"2026-01-06 15:00:00.000","0.0"
"2026-01-06 16:00:00.000","0.0"
"2026-01-06 17:00:00.000","0.0"
"2026-01-06 18:00:00.000","0.0"
"2026-01-06 19:00:00.000","0.0"
"2026-01-06 20:00:00.000","0.0"
"2026-01-06 21:00:00.000","0.0"
"2026-01-06 22:00:00.000","0.0"
"2026-01-06 23:00:00.000","0.0"
12/30/25 9AM, 10AM, 11AM intervals, the calculation returned correct value.
1/4/26 1PM, it returned correct value (17/60 min = 0.28)
1/4/26 3PM, it returend correct valuve (2/60 min = 0.033)
1/6/26 8PM it didn’t return correct value. I should have (14+11)/60 min = 0.416 however the calculation returned 0.233. 1/6/26 8:00:00 to 8:14:00 (14 min), and 1/6/26 8:49:00 to 8:59:59 (11 min)
And starting 1/6/26 8:49:00AM, the tag value stayed at 1, however the average calculation just returned 0 for every hours after the 8AM interval.
I have a few tags that are doing this and it seems to be always happening for the most recent data.

