Compare row workflow

Hello everyone,
I’m trying to write a workflow that compare the rows with the previous ones and as a result gives me an progressive index.
I’ll show you the example in this example in excel
example.xlsx (11.4 KB)

I found the “rank” node (with “dense” ranking mode") that allow to create a progressive index, but for some cases the node don’t increase the index (See orange lines in the excel file).

How can I fix this problem?..or there is a better way to implement this workflow?

thank you in advance!
cheers!

Andrea

Hi @ARuggeri91 , please check the Lag Column node

ok thank you, with this node I can shift datas from the preceding row; but I still don’t understand how to create the correct progressive index… I’m still tinking about comparing the acutal line with the preceding one and then increase the value.

Thanks
Andrea

Yes, comparing with the values of the previous row is what you have to do. I usually do this with Java Snippet, but it was fun to do it with “normal” nodes instead:

  1. lag all comparison columns by 1 row
  2. compare columns pairwise with lagged columns - if they’re all equal, put 0; otherwise 1
    so whenever a new group starts, there’ll be a 1, following rows of the same group will have a 0
  3. sum those increments cumulatively to get the “progressive index”. this is the excel equivalent of sum($A$1:A1) dragged down

    compare row workflow.knwf (32.1 KB)
2 Likes

Thanks! That’s work well!

Thank you all for the help! @Thyme @bruno29a

Andrea

1 Like

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