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.
Simple task - no solution in my mind. Thanks for your help guys.
Hi @The1Sigman ,
you can use “Column Expressions” to set the delta value for each row (0,1,-1) in column C
then you can substitute column C with the cumulative sum of its own values using the “Moving Aggregation” node
Hi @The1Sigman , welcome to the community!
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)
see the following post for more info on how this works:
Java snippets have long memories!...
many thanks for your help, @duristef it works pretty. Perfectly what I need.
Hi @takbb, many thanks for your solution. So I see, it’s time for working with the powerful Java Snippet. I’ll go learning…
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.
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.