Sequential Occurrence of consecutive Values in a Column

Hello,
I got the following issue.

I want to count occuring values.
I the value in the next row is the same, the counter should not add +1.

Does anyone know how to realize that in KNIME.
I could write python, but want to avoid that.

grafik

Thanks.

Hello @bzm9ba
2 Options

image

  1. Replicate your column by using String Manipulation [ join($Counter$) ] >> $new column$ (or with a ‘Rule Engine’…). Then you can test with ‘Group By’ node; by including both $Value$ and $Counter$ columns in:
    Group Settings (Groups Tab) >> Group column(s)
    and ‘Aggregation Settings’ $new column$ ‘Count’
    image

  2. ‘Group By’ node; by including only $Value$ column in:
    Group Settings (Groups Tab) >> Group column(s)
    and ‘Aggregation Settings’ $Counter$ ‘Unique Concatenate with count’
    image

The resulting matrix will give you different display…

BR

Hello Thanks for the suggstion,
but that is not the issue.
I want to generate the counter column, based on the Values.

@bzm9ba
Then you can try a ‘Rank’ node:

image

BR

1 Like

OK, but initially I do not have the counter column.

I want to create the “Counter” column based on the “Value” column

I got it,
Starting with $Value$ and generate $Counter$
Few more minutes to put it in nice…

Yes sorry,
I didn t find a way to modify my post

Hi @bzm9ba
I guess this answers the challenge:

20220920_sequential_and_consecutive.knwf (54.2 KB)

BR

PS.- Forgot to activate ‘Resolve missing values for incomplete windows’ 's check box in ‘Moving Aggregation’ node, as control for the last row.

Seems like you could also use a loop approach as seen here, but use the iteration number +1 as the count instead of moving average.

You would have to group by consecutive as well though.

Not as clean as I envisioned because of the need to apply the group loop to sequential occurrences only, but it was still a fun loop approach to test out.

consecutive_counting_rank.knwf (59.8 KB)