# Interpolating tag history to get count for a time or period

**URL:** <https://forum.inductiveautomation.com/t/interpolating-tag-history-to-get-count-for-a-time-or-period/56203>\
**Category:** Ignition\
**Created:** [February 16, 2022, 1:22pm UTC](https://forum.inductiveautomation.com/t/interpolating-tag-history-to-get-count-for-a-time-or-period/56203 "2022-02-16T13:22:44Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [February 16, 2022, 1:22pm UTC](https://forum.inductiveautomation.com/t/interpolating-tag-history-to-get-count-for-a-time-or-period/56203/1 "2022-02-16T13:22:44Z")

</div>

I have a tag’s value being logged (in the default historian) every time the run status changes (stop-to-run and run-to-stop). The production rate is fairly constant so interpolation should give a reasonably accurate cycle count. The cycle count does not reset at end of shift / batch.

What is the best way to get an interpolated count of machine cycles for a period of interest? I’ll be using these for a dashboard display so efficiency would probably be the important parameter.

Here’s an example of something that doesn’t quite work.

 ![Interpolated values](https://us1.discourse-cdn.com/inductiveautomation/original/3X/b/c/bcf0978a1c51535c25e1ea494f08fed524c1cd7a.png)  
_Figure 1. Test tables._

All three tables are looking at the same tag.

1. The DateTime selector is set to 11:00.
2. This table returns data from 30 minutes before 11:00 (10:30) until 12:30.
3. The ‘AsStored’ data shows a count at 10:54 and the next at 11:08. There is no record any closer to 11:00.
4. Same as (2) but with 1 minute periodic period setting.
5. The value for 11:00 looks about right about mid-way between the readings either side of 11:00 at (3).
6. This has the same binding as (4) but with the period set to 10 minutes and the time period is set to 11:00 to 12:00.
7. The first value returned is that of 11:09 in table (2).

It’s not at all clear what’s going on behind the scenes.

Is it possible to -

1. Retrieve an interpolated count value for 11:00?
2. Retrieve interpolated count values for 11:00 and 12:00?
3. Retrieve the interpolated count difference between11:00 and 12:00?

Further testing gives:

 ![Interpolated values 2](https://us1.discourse-cdn.com/inductiveautomation/original/3X/e/f/ef3bf7ef94adfd032343b65c87b5b5f9e3d5cfd6.png)  
_Figure 2._  
The Figure 2 tag history binding is set to

- Query mode: Periodic.
- Period: 1 MIN.
- Time Range: Historical.
- Start Date: = time setting.
- End Date: = time setting.

Is this my best approach?

Many thanks.

---

<div class="post-metadata">

**Author:** ![Bryan\_Mason](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bryan_mason/32/30612_2.png) [@Bryan\_Mason](https://forum.inductiveautomation.com/u/Bryan_Mason)\
**Post date:** [February 17, 2022, 9:11pm UTC](https://forum.inductiveautomation.com/t/interpolating-tag-history-to-get-count-for-a-time-or-period/56203/2 "2022-02-17T21:11:19Z")

</div>

I think the _Event meter_ in transaction groups was made for this. Check out this [video](https://inductiveuniversity.com/videos/hour-and-event-meters/8.0).

Also, I think this will solve a problem I’ve been working on: the hour meter will measure how long a condition is true.

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [February 17, 2022, 9:34pm UTC](https://forum.inductiveautomation.com/t/interpolating-tag-history-to-get-count-for-a-time-or-period/56203/3 "2022-02-17T21:34:53Z")

</div>

Thanks, Bryan, but that’s not quite what I want. I want to be able to return a reasonably accurate shift production count between two specified times. I’ve updated the question with a screengrab from a test application.
