Average Rate of Change of Tag

How could I calculate the rate of change of a tag? I think I could probably write a script that takes two reads on the tag at different times, but I want to know the typical implementation. This tag’s history is also being stored to the DB, but it doesn’t seem like a good idea to use this to find the rate of change.

There are several ways you could do this. You could set up a transaction group to log a tag value every 60 seconds, or whatever time interval you need, into a table. Then find the difference between the last two values. This would give you the rate of change per minute updating every minute. The shorter the capture time the more instantaneous the rate of change, the longer the capture time, the more average it will be. Finding the difference between the two values will be determined by the type of db you use with the transaction group.

Thanks, that’s a really simple setup


I am currently trying to do this but am struggling to figure out how to script with the latched value of the tag that I am trying to subtract from the Source value. Do you have any idea how to use the latched value in the scripting of the transition groups themselves/expression items/SQL queries? Thanks!

I think the best way is to just log your values with the transaction group like normal, then you determine the change between records using a lag() window function in your query depending on the DB flavor.

1 Like

i've implement the rate of change at tag level with this ressource.