grouped counter

Hi, I have the following problem:
I need to do a grouped counter type. For example, I have a column (situation) that, as long as it is different from 67, this counter will be 0. When “Situation” is 67, the counter adds 1 and becomes 1. When “Situation” is 67 again, the counter adds plus 1 and becomes 2 … and so on.

Hi @renantex

See this workflow that produces the result you expect. The “trick” for the solution was the first Missing Value node in the flow that converts all missing to the previous value. grouped_counter.knwf (41.2 KB)

gr. Hans


Hi @renantex,

you also can use a simple java snippet.



Hi @HansS,
its flow works fine, but the Java Snippet indicated by morpheus is simpler.
Thanks a lot for the help.


Thank you @morpheus .
simple and objective. Worked perfectly.

1 Like

It would be interesting to see solution for Column Expression node. I tried but failed with syntax.

Can you upload your workflow or post a screenshot of your syntax?

Hi there @izaychik63,

you can not change KNIME flow variable in Column Expressions node. That where error comes from I believe.

Also not sure there is solution for Column Expressions node as it evaluates all code against each row without remembering previous state/value of variables. Have a feeling all variables declared inside Column Expressions node are local.


Ivan, I sent variable as parameter but any way what you saying sounds restrictive.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.