Addition and subtraction by day of the week

Good morning people, everything fine ?

I have a big challenge again. I would like to explain it to you and I look forward to everyone’s help in finding the best solution.

Well, I have a volume of packages that must be sent daily, but my stores have a receiving capacity. I would like this to be subtracted and the difference added to the volume I have to send the next day.

Example: For 2023-10-12 I have a sending volume of 9000 and a receiving capacity of 8000, so there will be 1000 left. And for 2023-10-13 I have 8000 + 1000 (remaining from the previous day ) and so on for the rest of the week.

KNIME_project - Volumetry.knwf (4.7 KB)

You can just use the Lag column to duplicate your quantity column and drop it down by 1 row.

In your example: That way the 9000 and 8000 are on the same row. Then you would subtract the lag qty column from the original to get your difference. (9000-8000=1000)

After that it gets kind of vague what the result column should look like. Not sure if you want to actually add that back to the original column afterwards, but you can use the Math or Column Expressions nodes to do these expressions easily.

This assumes that there are no special conditions when this calculation should not occur, such as more than 1 day passing between rows or the changing between a defined week.

1 Like

I sent you a print, following this example. On 2023-10-09 I can send 100% of my demand, and I have 0 BACKLOG, on 2023-10-10 I have 1163 BACKLOG so on 2023-10-11 I have the demand of 12092 + 1163 Totaling 13255 - 8000 (my receiving capacity) I have a backlog of 5255.

Basically he needs to look at the previous day and check if he has a backlog, if so, he needs to add it to the demand and subtract it from the capacity and so on for the rest of the days.

the week is always closed in 7 days.

It looks like you can just use the Lag node on “Backlog” to simplify things to a single row calculation.

People and entities have different definitions what consists of a “week”. What is the start and end day of the week?

Could you send me a worflow with this node please?

Sure. What is the first day of your week? (Do you start it on Sunday or Monday?) I can put that in as well.

Firstly, thank you very much for your help, it always starts with the monday.

I have something started over here, but I can’t tell how you are calculating BACKLOG… Look at column F on the Date 2023-10-12. How did you arrive at 7,143? It seems like there may be some circular reference logic going on?

The backlog column is the forecast value - capacity. And the new forecast column has to be the previous day’s backlog value + the current forecast value.

See if this accomplishes your result goal.
KNIME_project - Volumetry.knwf (90.7 KB)

Be sure to do some testing and review . It was difficult for me to internalize your calculation descriptions as they referenced columns that I would need to calculate and create. I believe that this is what you were describing though.

1 Like

AMAZING, that was exactly it.

Can you help me with just one point, I’m including it in my general flow and the calculations are giving me an error.

KNIME_project2.knwf (34.7 KB)

Ataa I think I know what it could be, some operations start on Tuesday maybe that’s it

There are some strange numbers, I’m trying to understand the logic you used to apply them, but I’m counting on your help to finalize these adjustments. Thank you very much, I don’t know how to thank you, this will help me a lot.

One more point I filtered so that every day was from the same week.

In the example I sent you, the week starts on 10/09/2023 and ends on 10/15/2023, but as I don’t have a load on the 15th it goes until the 14th

It was clearer with the additional Data. I grouped it by the Origin / Destin / Week / Year. (Purely based on the assumption that differences in Origin would represent a different event as well)

Take a look. It required a loop approach now that there was increased variability in Grouping, starting days, reset points, etc.

KNIME_project - Volumetry.knwf (447.4 KB)

Yes, it must be calculated according to destiny. I think it’s just an adjustment to some logic, probably in the expression column, but I’m not able to come up with a rationale. I sent the complete table above, can you help me again?

I’m sorry for the inconvenience.

I believe the solution is in this node, what would this variable be??

Check my post above. I had a prior response open for editing…

An important point, if the BACKLOG is <0 => 0, the Forecast Value column will either show the same value as the Shipping volume column or it will add up to the Backlog generated the previous day.

and it will look like the print below

KNIME_project - Volumetry.knwf (531.0 KB)

Like this?