How to calculate the average of past months depending on the date?

Hi KNIME community,

I’m a new user and I hope you can help me with my problem. I have 2 tables:

Table1:
image

Table2:
image

So I want to build a workflow, that in table 1 a new column shows the average of the current month and the previous two months from table 2.

For example for Müller: (25+63+48)/3 = 45,3

So i don’t know how to create the workflow, if you can help me, it will be very nice.

Thank you.

Oh and I forgot that Müller in Table 1 lives in München. Maybe this should make it clearer:
Table 1:
image
Table 2:

Hi @Robo, welcome to KNIME Forum

A question, can there be multiple rows of the same city in table 1 and/or table 2. Or is City unique?

gr. Hans

Hi @Robo

I connected some nodes together in this calc_average_last3_months.knwf (92.1 KB) workflow. I used a Column Appender because I assume the order of both table is the same (?). I also created a date back in time (3 months) that will be used later on to do the filtering in the DateTime Based Row Filter. Because the dates differ per row,I used a Chunk Loop to do the calculation for every in the table. Hope this give you some directions to solve your problem.


gr. Hans

4 Likes

Hi @HansS ,

thanks a lot. I’ve tested it with my data and it works very well :slight_smile:

3 Likes

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