Dynamic 7 day rolling window

Hi ,

I’m trying to create something like below. Basically I have a list of records with dates and metrics, I wanted to group records based on rolling 7 day window and give the min and max day for that 7 day period. How can we accomplish this in knime ?

Date Sales 7day win
12/10/2018 3873.559 12/10/2018 to 12/16/2018
12/11/2018 2025.035 12/10/2018 to 12/16/2018
12/12/2018 ? 12/10/2018 to 12/16/2018
12/13/2018 580.936 12/10/2018 to 12/16/2018
12/14/2018 3897.714 12/10/2018 to 12/16/2018
12/15/2018 306.888 12/10/2018 to 12/16/2018
12/16/2018 858.702 12/10/2018 to 12/16/2018
12/17/2018 2027.758 12/17/2018 to 12/23/2018
12/18/2018 3645.911 12/17/2018 to 12/23/2018
12/19/2018 1895.926 12/17/2018 to 12/23/2018
12/20/2018 377.736 12/17/2018 to 12/23/2018
12/21/2018 2140.94 12/17/2018 to 12/23/2018
12/22/2018 7442.021 12/17/2018 to 12/23/2018
12/23/2018 1926.776 12/17/2018 to 12/23/2018
12/24/2018 6233.054 12/24/2018 to 12/30/2018
12/25/2018 2698.927 12/24/2018 to 12/30/2018
12/26/2018 814.594 12/24/2018 to 12/30/2018
12/27/2018 177.636 12/24/2018 to 12/30/2018
12/28/2018 1657.3508 12/24/2018 to 12/30/2018
12/29/2018 2915.534 12/24/2018 to 12/30/2018
12/30/2018 713.79 12/24/2018 to 12/30/2018

Hi @naveenn08

See this wf 7-days-window.knwf (22.6 KB). When your date column has also a date-format, you can extract the week number by using the Extract Date & Time Fields node.
Schermafdruk van 2023-04-21 07-30-12
gr. Hans

2 Likes

Hi Hans,

Thanks for your suggestion, I initially thought about this approach but was unable to use the week number to group records as I wanted the window to be a 7 day dynamic rolling window, meaning if the current day is Tuesday then I wanted the records for prior 7 days from Tuesday.
But I was able to use an alternative approach to group records for rolling 7 day window. Please find the workflow attached.

7-days-window2.knwf (45.6 KB)

1 Like

Hi @naveenn08

Unfortunately your wf is empty… (uncheck: Reset Workflow(s) before export), so I can’t see what is actually happening in your wf. But I see you found a solution yourself, top!
Maybe you have time to check out the Window Loop Start node, that is designed to create a rolling window.


gr. Hans

1 Like

Try this workflow. It produces the min/max values for any arbitrary sized window (currently set to 7.) Each date in the output table has the min/max values for the entire window. The workflow filters out dates which don’t have a full size window.

I misread your original post. I didn’t realize you wanted the high/low dates as well as values. This workflow should work.

1 Like

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