# Logging flow totals

**URL:** <https://forum.inductiveautomation.com/t/logging-flow-totals/9525>\
**Category:** Ignition\
**Created:** [January 12, 2015, 2:07am UTC](https://forum.inductiveautomation.com/t/logging-flow-totals/9525 "2015-01-12T02:07:40Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Micky.Franks](https://avatars.discourse-cdn.com/v4/letter/m/c57346/32.png) [@Micky.Franks](https://forum.inductiveautomation.com/u/Micky.Franks)\
**Post date:** [January 12, 2015, 2:07am UTC](https://forum.inductiveautomation.com/t/logging-flow-totals/9525/1 "2015-01-12T02:07:40Z")

</div>

I have a dump scale that’s measuring flow rate of a stream of rice which has a accumulator to poll. Right now I am using Wonderware to poll every hour and take the current total and previous total and move the difference to a database and the current value to a register for a reference for the next hour, basically a totalizer.

I would like to do the same thing in Ignition but don’t know if it would be better to use a script that runs at the hour as in Wonderware or if this is something that could be done in a transaction group.

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [January 12, 2015, 10:46am UTC](https://forum.inductiveautomation.com/t/logging-flow-totals/9525/2 "2015-01-12T10:46:20Z")

</div>

Personally, I’d go with a transaction group. That way, if you happen to lose connection to the database, the Store and Forward engine will hold the entries for you until it restored.

Just my 51-cent’s worth (adjusting for inflation). 😉

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [January 14, 2015, 1:39pm UTC](https://forum.inductiveautomation.com/t/logging-flow-totals/9525/3 "2015-01-14T13:39:58Z")

</div>

This is my mockup transaction group with three items:

 ![](https://us1.discourse-cdn.com/inductiveautomation/original/2X/e/eb003591965cf0635c922e10e9f9f7dae7c46703.png)  
  
last\_flow reads the last entry in the database.  
 ![](https://us1.discourse-cdn.com/inductiveautomation/original/2X/7/7252620b2ce93ea63fc32b2826098ccf902fda4e.png)  
  
total\_flow reads from the SQL\_Tag. In this case, it’s from the SLC Simulator.:  
 ![](https://us1.discourse-cdn.com/inductiveautomation/original/2X/c/c495f823fd433679b15d8842981c396ebf297f69.png)  
  
delta\_flow is the difference between the two:  
 ![](https://us1.discourse-cdn.com/inductiveautomation/original/2X/3/3302331c8cc8aff1e3a78f2e5b96602939b45360.png)  
  
My usual preference is to log both the accumulator value and the delta value. That way, you can have an extra bit of historical data to play with.  
 ![](https://us1.discourse-cdn.com/inductiveautomation/original/2X/e/e76a19e842556a63daf4c6ec39bf1d25d173c929.png)

---

<div class="post-metadata">

**Author:** ![Micky.Franks](https://avatars.discourse-cdn.com/v4/letter/m/c57346/32.png) [@Micky.Franks](https://forum.inductiveautomation.com/u/Micky.Franks)\
**Post date:** [January 14, 2015, 2:54pm UTC](https://forum.inductiveautomation.com/t/logging-flow-totals/9525/4 "2015-01-14T14:54:23Z")

</div>

I actually just figured this out about 30 mins before you posted. I did it pretty much the same way except where I created the reference tags. I like your way better, it’s better organized.

I created a SQLTag for reference which is a query

` SELECT COALESCE (Headriceaccum,0) FROM reportingsandbox
ORDER BY reportingsandbox_ndx DESC
LIMIT 1;`

Then in the transaction group I log the accumulated, reference and calculated total every hour.

The added bonus I discovered using transaction groups is I can build a sql table like I need for a report without having to do a bunch of sql scripting.
