Hi everybody

I am looking for a function in PI AF to calculate a rolling sum. I have found the function "TagTot". But this works on a time integral basis. In my case I need only a sum.

I had some ideas to work with an infinite counter and a range function. But I think there must be an easier way.

Thanks in advance.

You can use a combination of TagMean and EventCount.

If (EventCount(‘Tag’, ’start time’, ‘end time’ ) > 0) then

TagMean(‘Tag’, ’start time’, ‘end time’ ) * EventCount(‘Tag’, ’start time’, ‘end time’ )

Else

0

I've used it a number of times and had to use it again recently; I confirmed the results to looking by pulling values for a set of tags into Excel using Datalink and manually checking the sum.