# Calculate difference in Tag History

**URL:** <https://forum.inductiveautomation.com/t/calculate-difference-in-tag-history/84711>\
**Category:** Ignition\
**Created:** [January 24, 2024, 4:26pm UTC](https://forum.inductiveautomation.com/t/calculate-difference-in-tag-history/84711 "2024-01-24T16:26:35Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![JoseJardelLuciano](https://avatars.discourse-cdn.com/v4/letter/j/35a633/32.png) [@JoseJardelLuciano](https://forum.inductiveautomation.com/u/JoseJardelLuciano)\
**Post date:** [January 24, 2024, 4:26pm UTC](https://forum.inductiveautomation.com/t/calculate-difference-in-tag-history/84711/1 "2024-01-24T16:26:35Z")

</div>

I have a tag that receives energy consumption data (where the value is increased over time).

I configured the History Enabled option to have the tag's history.

I'm trying to create a table to show consumption data every 15 mins.

I configured the Tag History option using the options in the attached image.

 ![Screenshot_5](https://us1.discourse-cdn.com/inductiveautomation/original/3X/f/a/fad89d4e4084783c98ae9aad9cccd80ce62a5276.png)

How could I calculate this difference between the minimum and maximum value and show it in a new column of this table?

---

<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:** [January 24, 2024, 5:45pm UTC](https://forum.inductiveautomation.com/t/calculate-difference-in-tag-history/84711/2 "2024-01-24T17:45:04Z")

</div>

Ignition's Tag History does not do a good job for this type of application. It doesn't interpolate / extrapolate to the 15-minute boundaries you're looking for and will miss information at the start and end of the time range in the returned data (if there is no record right at the boundary).

I recommend:

- Create a dedicated table for the energy meters. Add columns: timestamp (indexed), meterName (indexed), kW, kWh, etc.

- Create a gateway scheduled task - Menu → Project → Scheduled.  

- On the script tab write a script to,

You will now have a dataset that is synchronised with the utility meter and this can be useful for monitoring maximum demand, etc., and calculating cost on variable tariffs.
