Question about multi-row formula in Alteryx

Hi guys, I want to migrate Alteryx workflow into KNIME workflow. There is a multi-row formula node in Alteryx like this.

It simply gives values to column(Group ID) according to the values in column (2). If column(2) contains “com”, the values in column(Group ID) +1, else the values in column(Group ID) = value in the last row. The output should look like this.

Can anyone help me solve this problem? Thanks!