Need help replicating an excel formula in KNIME. I’ve include a sample excel file with dummy data for reference.
Essentially I need create a column that increments 1 every row where the previous attribute value is the same as the current one. Once the attribute has a new value, I need to grab a new value to start again. I already have my dataset structured and sorted appropriately.
I would use a Lag Column node for both your attribute and value columns, then all of the necessary values are on the same row for you to do an if statement to compare the attributes. If the Lag and original attributes are different then the new value = the old value, else the lag and old attributes are the same and the new value = the lag value +1.
@iCFO Thanks so much. Using 2 Lag Column nodes in a row caused an “Encountered Duplicate Row ID” error, but I was able to work around that by combined my attribute and metric columns, lagging the combined column, and using a Cell Splitter to split the lagged column.
What node would you recommend to implement an IF statement? The Math Formula node only numbers, so I can bring in my string attribute in the IF statement.
The Lag column drops those prior row values to the same row, so it should be as easy as referencing those lag columns in the statement rather than using a fancy multi row formula.
Renaming those lag columns to something like Prior Row Attribute and Prior Row Value might help.
I will try to upload a demo workflow for you and I when I get back to the office.