If a column value is greater than 12, add 1 to another column

Hi team,

How to add a constant value to another column if criteria is met in first column?

Hi @nidhichirania , and welcome to the Knime Community.

There are a few different ways you can do this.

However, since you are dealing with numbers only, it’s probably more straight forward to use the Math Formula to do this:

You can also use the Math Formala (Multi Column) if you want to do the same operation on multiple columns at the same time:

I put together a workflow that uses both nodes, and it looks like this:

My initial data:

The Column1 is the column where we evaluate if the value is greater than 12 or not.

Single Column update (only “another column1”:
Uses the condition: if($column1$ > 12, $another column1$ + 1, $another column1$)

As expected, Row0, Row1, Row2, Row6, Row7 and Row8 will not update as column1 is less than or equal to 12.

Multiple columns update:

In this case, all of the “another column1”, “another column2”, “another column3” got updated, and since it’s using the same initial data as in the single column update, Row0, Row1, Row2, Row6, Row7 and Row8 did not updated as expected.

Here’s the workflow:
Add 1 to another column if a column value is greater than 12.knwf (9.4 KB)


Hey, Thanks for taking out the time and explaining in detail. Lovely!


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