I would like to count the number of consecutive values in the “Calc Vol” column that are above the constant value given in the “Upper Limit” column
e.g, here the count would be 2 as there are only 2 values above 22.95 that come after each other (rows 8 and 9). I’m only concerned about values above the 22.95 if they are followed by another value above the 22.95. Do you know if this is possible?
I think you should be able to do this using the Column Expressions node - available in the KNIME Expressions extension.
Connect the table you provided in your screenshot to a Column Expression node. In the “Advanced” section of the configuration of this node, make sure you’ve enabled “Multi-row access” and select “Use ‘null’” for the first and last rows. Then create a new expression with the below configuration.
Then connect the output of the Column Expression node to a GroupBy node and sum the new Count Column.
Thanks so much for your response, it helped a lot!
It’s very nearly what I am looking for; is there a way I can get the new “Count” column to count consecutive entries, i.e in the screenshot below at row 9 it would read 2, and then at Row16 it would read 2 again, but it would not read 4 as once the value falls below 22.95 the count refreshes again?
Thanks a lot
Hi @KAnderson ,
The best way I know of in KNIME for performing cumulative functions across rows is with a Java Snippet.
The following would do what you want I think
In the custom variables section:
In the Enter your code here section:
out_RunningCount = curCount;
with my own dummy data set this produces:
You could of course redo the whole thing with a java snippet, but to be honest unless performance is an issue, I’d stick to small steps that work to reduce complexity, and if the column expressions is working, then simply bolt this on the end.
Amazing, that worked perfectly!
Thanks so much
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.