How to set lag no.as variable to run loop in Lag column

Hi Knime experts
I have below part with difference lag request for demand.
image
I use table row to variable loop start to set lag no. as variable, but I don’t know what’s wrong, the workflow can get the result what I want.
Thanks for help in advance.

Below picture show my workflow result and what I want, hope it’s clear for understanding.

Hi @Chenfang,

is something like this working for you?

Let me know,
RB

Hi Lelloba
Thank you so much for your prompt reply and perfect solution. It works.

Hi Lelloba
I have another question, if I want lag with negative, how to set up, thanks!
image

In that case you have to use another node called Moving Aggregation.

See this post: Lag Column with Negative value? - #8 by Isabell

Alternative: this node

RB

OK, thanks, let me try.