# Water metering historical data

**URL:** <https://forum.inductiveautomation.com/t/water-metering-historical-data/56242>\
**Category:** Ignition\
**Created:** [February 17, 2022, 7:38am UTC](https://forum.inductiveautomation.com/t/water-metering-historical-data/56242 "2022-02-17T07:38:38Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![paul1](https://avatars.discourse-cdn.com/v4/letter/p/3d9bf3/32.png) [@paul1](https://forum.inductiveautomation.com/u/paul1)\
**Post date:** [February 17, 2022, 7:38am UTC](https://forum.inductiveautomation.com/t/water-metering-historical-data/56242/1 "2022-02-17T07:38:38Z")

</div>

I have a water meter pulsing to a plc input and incrementing a totalising counter at PLC level.  
This value is cumulative and is being logged into ignition SQL database every 5 minutes.  
I wish to generate a timescale graph to display the number of pulses every hour . This would show the difference or delta of the reading between each hour to determine the rate of change throughout the day.  
Do I use variance aggregate mode? Will this calculate the difference between the data table samples

---

<div class="post-metadata">

**Author:** ![lachguerabdallah](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lachguerabdallah/32/25558_2.png) [@lachguerabdallah](https://forum.inductiveautomation.com/u/lachguerabdallah)\
**Post date:** [February 17, 2022, 12:38pm UTC](https://forum.inductiveautomation.com/t/water-metering-historical-data/56242/2 "2022-02-17T12:38:48Z")

</div>

you can use a tag change script. each time the tag changes, write the difference to another tag and historize it.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [February 17, 2022, 1:21pm UTC](https://forum.inductiveautomation.com/t/water-metering-historical-data/56242/3 "2022-02-17T13:21:08Z")

</div>

You would use your database’s `lead()` or ‘lag()` window aggregate function to pull adjacent rows’ values into a subtraction operation on the current row. Do that in a subquery where the outer query sums that difference and groups by hour.
