How to sum a value in a ranged time


What I want to do is sum the three marked values, and the new row id must be the first value. I’ve tried a lot, but didnt achive any result

Hi @MrWednesday0 welcome to KNIME Forum

Do you want to sum only the first 3 records of your file, or do you want to sum every group of 3 records in your file?
gr. Hans

1 Like

Yep, sum every group of 3 records,
Like
A 1
B 1
C 1
Result should be A 3, next 3 records does the same

Could you be a little clearer about what the output should look like?

1 Like

Hi @MrWednesday0

Are you looking for something like this sum_values_in_a_ranged_time.knwf (137.0 KB)


gr. Hans

2 Likes

Hi @MrWednesday0 & @HansS

I hadn’t thought about using a group loop purely to capture group ids. That’s a nice easy solution with no coding.

Alternative for getting grouping numbers would be Math Formula:

floor( $$ROWINDEX$$ / 3)

Use of the GroupBy would be the same as per the above flow, but would now group by the column produced by Math Formula instead of the loop iteration.

The only thing I’d add in response to the final part of the original post is that the RowID node can be used to replace the RowIDs with the dates returned by the groupby, if you really want to set the new Row IDs. The various options to ensure uniqueness and maybe remove the original column could be set as follows (borrowing from @HansS 's solution for my screenshot):

2 Likes

@HansS and @takbb, thanks for the help. Both of yours solution worked very well.

1 Like

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