if else statement with column expression


Based on value in the column a, i am trying to get ((column b) - 7) else column b. I tried with column expression node, but what ever the condition, i am getting column b as output. seems like i am missing something, could anyone assist on this. Below are the details for your reference.

ColumnA ColumnB ColumnC
V001 3 =(columnB)-7
V001 1 =(columnB)-7
V001 1 =(columnB)-7
V001 4 =(columnB)-7
V001 2 =(columnB)-7
V014 -74 -74
V014 -72 -72
V014 -17 -17
V014 -10 -10
V014 -22 -22
V014 3 3
V014 107 107
V015 -86 -86
V015 118 118
V015 41 41
V014 319 319
V014 326 326
V014 330 330
V014 334 334
V012 -71 -71

condition used in column expression:

column(“ColumnB”) - 7;


Check the length of column A. It may have leading/trailing spaces or other extra symbols.

1 Like

i did check and there is no issue with the length.


What’s the data type of column B?

Hi @pawanmtm and welcome back to the KNIME community forum,

Everything here looks fine and should work properly. As @izaychik63 mentioned, there should be something wrong with the values of “ColumnA”, so the condition for “if” never becomes true.

In addition to what is already guessed by @izaychik63, I suggest you check the uppercase/lowercase letters like “v001” and “V001”.

If you cannot find the problem, you can upload an example workflow here and we can check it for you.


1 Like

I think we’re misinterpreting his words - his screen shot shows the if-else working correctly (the first 5 rows) - just not the calculation of the value.

Hey @quaeler,

I think the table is not a screenshot. He has provided what he expects to get as the output. Since he wants to make it clear how the result should be calculated, he has entered the formula instead of the final result.


Seems plausible. @pawanmtm can you attach your workflow?

1 Like

I just checked thoroughly and found some issue with the input file which has “Vo01” for few and “V001” for some other rows. I have corrected them and now i have the correct output available.

thanks to @izaychik63, @quaeler & @armingrudd for your time and responses.



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