Hi there,
an issue, I can’t find a solution for column C, yet.
From row to row I like to count up if a cell in column A has a value. A counting down when the cell in second column B has a value.
A|B|C
?|?|0
x|?|1
x|?|2
x|?|3
?|x|2
?|?|2
?|x|1
…
Simple task - no solution in my mind. Thanks for your help guys.
Boris
Another method is to make use of a feature of the java snippet node which works well for row-by-row cumulative computations provided you know some basic java. Count Up If - using java snippet cheat.knwf (7.4 KB)
Yes it’s good to know the features of the java snippet node. Although I’m from a java background I try to avoid using it unless it makes obvious sense to do so as i prefer the no-code solutions where possible, to save myself from bugs and extra testing. But yes it is a powerful tool, with some limitations, and as you can see for certain jobs it can save a lot of effort.
The python script node is also very powerful, if you have python installed and has some advantages over the java snippet node in that it allows you to work on the entire table as a dataframe, so you can often achieve this with python that you cannot achieve with the standard nocode nodes or the java node. (The java snippet works only on a single row at a time and so you cannot directly reference values from other rows).
The downside of using python as a solution for somebody else is that it requires they have installed python, and configured it in KNIME, whereas the java snippet works for everybody out of the box.
Again I use python script node only where i can’t achieve my goal elsewhere; preferring not to have to debug my code where I don’t have to. So it really is a case of having the tools at your disposal and then choosing the best (for you) for the given job.
Btw, I understand that the R node is also very powerful but I’m not familiar with R.