# Number the rows by condition

Hello! I`m trying to number the rows by condition, i mean if meet the condition number increase by 1 . It is simple to do using excel table but in knime i don`t know how to do it.

On example picture A - condition, B - the result i want to get.

thank you in advance for any idea.

Hi @spa_rr_ow , itâ€™s not clear what you are asking.

What is the rule/condition?

And what is the input data? Is it column A or column B

EDIT: Ok, I think I understand: â€śA - condition, B - the result i want to getâ€ť

So input data is A, and B should be the result

yes you a right. Actually my upper level task is aggregate column between specified time stamp.
A - B - C
0 - 01/03/2022 15:00 - 10
1 - 01/03/2022 15:16 - 20
2 - 02/03/2022 09:58 - 5
3 - 02/03/2022 10:07 - 3
4 - 02/03/2022 10:07 - 1

I have to calculate Average(Sum, Count etg) value taking from column C only for rows between 1 and 3.

Hi @spa_rr_ow , I donâ€™t quite understand the newest explanation.

But I put something together for your initial sample.

Input data:

Note: I had to add the last â€śtestâ€ť (Row 15) in order to get the empty rows after the second test (Row 9).

Results:

Workflow looks like this:

Hereâ€™s the workflow: Number the rows by condition.knwf (12.3 KB)

1 Like

Thank you so much. This exactly what i need. I never use Moving aggregation before.

Hi @spa_rr_ow , itâ€™s probably not the most common use of the node in this case, but in general, the Moving Aggregation is a very useful node, especially for doing cumulative aggregation.

You can see a more common use of the node here:

2 Likes

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