AnsweredAssumed Answered

PI Datalink - Obtain Total sum by using NextVal() in Filter

Question asked by lvfh on Sep 10, 2019

I'm trying to grab a total from a pi point that resets to 0 at different times or values. The example below gave me the answer on how to get the values before it resets to 0, using NextVal(). This is good, but I don't want ALL the values individually. I want a sum. How can I use the NextVal() function as a filter for calculated data??? I have tried =PIAdvCalcFilVal as a total, but no success.

The answer BELOW the example shows two values, 5 and 19. I instead want the sum as one value 24.


EX below using compressed data from an old thread:

I'm using compressed data to display reject rates on a packaging line. This tag counts bags rejected during a batch. I want to only capture the last value before it resets to 0. That way I can just see that batch x had y rejects.


So in this example, the first batch had 28 rejects. It automatically resets to 0 and begins counting rejects for the next batch. I only want to display 28. And then the value for the next batch. How can I do this?



Correct Answer

Hi Morgan,

I believe you can get the reject count for your batches by using the filter expression NextVal('reject tag','*')=0 in your compressed data function. This will only show values prior to the 0 values. Here is my quick test of this:

5 and 19 after resets


Please let me know how this works for you and if you have further questions.