basically I want to do something very easy namely to calculate a gradient that is

column.value[i] - column.value[i+1]

with the moving aggregation node I found a close solution by setting the window length to 2 and setting the aggreagtion to â€śRangeâ€ť. Only problem is that it will always calculate the difference between the largest and smallest element of the group.

So I thought I will write some code in a JavaSnippet but it just wont work. I donâ€™t really know the correct syntax in this snippet.

Something like

Double output_vectorCa = new Double [$input_vector$.length];

for (int i = 0; i < $input_vector$.length; i++){
output_vectorCa[i] =$input_vector$[i] - $input_vector$[i+1]
}
output_vector = ;output_vectorCa

You could also use the Lag Column node to shift the column by one, followed by the Math Formula node to subtract the shifted and original columns from another.

But I actually found a solution via JavaSnippet.
I always forget that KNIME works Row-based. Therefore the JavaSnippet calls the method function consecutively for every row.

if i understood you correctly you try to doe the calculation based on specific groups. Therefore you first have to sort your data in right manner and then check within your statement if the group is different to the previous row. Otherwise you get a wrong value for the first row within a group.

no no. That was just an example how I semi solved it before. I created groups of 2 to then aggregate via Range.
But what I really wanted to do is to build the difference Row_1 - Row_2 of one Column, to which I found a solution