grouped counter

users
workflow
#1

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.
example:
image

0 Likes

#2

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

2 Likes

#3

Hi @renantex,

you also can use a simple java snippet.
screenshot

screenshot3

5 Likes

#4

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

2 Likes

#5

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

1 Like

#6

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

0 Likes

#7

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

0 Likes

#8

0 Likes

#9

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.

Br,
Ivan

0 Likes

#10

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

0 Likes

closed #11

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

0 Likes