Compare rolling dates / compare previous 12 months

hi all,

I am quite new to KNIME and unfortunaltely stuck in a comparisson i want to set up.

I want to compare the values of rolling dates in a table. For every month I need to check the amount column of the previous 12 months (see column example 1,2, table below). The task is to automatically filter all dates, that have at least 6 or more (out of 12) previous months where amount = 0 

ID Amount Date    
A 0 201509    
A 0 201510    
A 0 201511    
A 0 201512   check if Amount=0
A 0 201601 check if Amount=0 check if Amount=0
A 3 201602 check if Amount=0 check if Amount=0
A 5 201603 check if Amount=0 check if Amount=0
A 0 201604 check if Amount=0 check if Amount=0
A 0 201605 check if Amount=0 check if Amount=0
A 1 201606 check if Amount=0 check if Amount=0
A 2 201607 check if Amount=0 check if Amount=0
A 0 201608 check if Amount=0 check if Amount=0
A 4 201609 check if Amount=0 check if Amount=0
A 3 201610 check if Amount=0 check if Amount=0
A 3 201611 check if Amount=0 check if Amount=0
A 0 201612 check if Amount=0 Start date
A 0 201701 Start date  

I need to repeat the procedure for every entry in the date column. Does someone have a "simple" solution for it?

Thanks a lot!

Best,

Stephan

Hi Stephan,

I have a "simple" solution if your table contains all month. (otherwise you need to ensure this beforehand.

1. sort by date

2. Generate a new column which is a missing cell if the value is 0 and does contain a 1 otherwise (Rule Engine node)

3. use the moving aggregation node, use Backward, Window Length 12 and on your newly created column the Missing Value count.

4. On this column you can than filter with the row filter.

Let me know if this was what you were looking for!

Cheers, Iris 

Hi Iris,

it did the job. Thanks!

Anyways I wasn't to specific about my problem. I need to include another filter, as I have different IDs I want to limit the moving aggregation column to:

ID Amount Date
A 0 201601
A 2 201602
A 0 201603
A 0 201604
A 0 201605
A 3 201606
A 5 201607
A 0 201608
A 0 201609
B 1 201601
B 2 201602
B 0 201603
B 4 201604
B 3 201605
B 3 201606
B 0 201607
B 0 201608
C

So I want to check the last 12 month for date 201604 on ID B and the check shall stop after window length 12 OR if the ID is not = B. I hope I could explain my problem properly.

 

Thanks a bunch!

Stephan

--- double post

--- double post

--- double post

--- double post