How to count values of the same group, with intermediate counter reset?

Hello @aesposito -

Here’s one way you could do it, without a loop. This workflow uses the Moving Aggregation node to look forward in the data, and then does some manipulation on the results to determine what the final values should be. I’ve left the interim steps as individual columns in the table so the logic is a bit clearer.

The downside is that this workflow is hardcoded to look ahead 5 observations. It’s easy enough to change that in the Moving Aggregation node, but still, it’s something to be aware of. As usual with most workflows, there is probably a more elegant way to do this, but hopefully this is enough to get you started.

2018-09-14%2013_27_38-Classified%20values%20-%203_35%20-%20Rule%20Engine%20(Correct%20for%20_1_)

LookForwardExample.knwf (14.1 KB)

2 Likes