Add new column with variable value based on existing column value

Hi everyone,
I want to add new value based on existing column value.
Below table illustrates the data structure I want to achieve.

Based on the value of column “date&time diff vs previous”,
I want to add variable value into process ID column.

Can anyone help?
Many thanks in advance,

Keith

Hi @KeithinDT

See this wf switch_process_id.knwf (45.6 KB). Your are not clear about the logic that makes ProcessID switch one up, so in the RuleEngine node I assumed the value must be above a certain level. Anyway hopes this helps.


gr. Hans

2 Likes

Thank you Hans for your kind reply.
Allow me to explain the logic a bit more specific.

Process ID is supposed to add one up when the “Start_Time” passed over 1 hour compared to the previous column. If not, the same process ID will be given. So I calculated the time lag and saved as “date&time diff vs previous” for each line.

I was thinking about using loop to do this, but couldn’t make it.
Your wf solution gives me hint. Thank you so much!

Keith

1 Like

Hello
search for lag column. Lag label by one
then use a formula , if lable =lag-1 , 0 else 1 to create a new column
Finally search for a cumulative node ( moving aggregation) to take the running total of this new column
it should work. In case don.t please update the data sample so we can try it out

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