Column Expression Node: Comparing values across multiple rows

Hi everyone,

I’m struggling to get the following code for the column expression node right:

if (
column(“A”) - column(“A”, -1) < 0 // difference is smaller than 0 (negative)
&&
column(“B”) <> column(“B”, -1) // change in values between rows
)
{column(“C”)}
else {toNull(“”)}

Could anyone point out my mistakes?

Multi-row access is activated:

image

Thanks and best,
Eren

Do you get a particular error message when trying to execute it?

1 Like

Hi,
It seems to work with these modifications :


or

column("B") != column("B", -1)

Best,
Joel

4 Likes
var aCheck = column("A")-column("A",-1)
var bCheck = column("B")-column("B", -1)

if(
    and(aCheck > 0, bCheck != 0)
    ) {
        1
    } else {
        0
    }
    

Debugged a little and can confirm: “not equal” operator must be “!=” and not “<>” :slight_smile:

3 Likes

@JPollet @MartinDDDD Thanks a lot for your quick help! Both your solutions work like a charm!!

@ArjenEX thanks for taking the time to ask. Unfortunately, I forgot to take a screenshot of the error message.

ps:

do you happen to know if there is any kind of resource where one can learn more about the coding syntax for KNIME nodes (Column Expression, Rule Engine, etc.)?

1 Like

No problem :).

Regarding documentation:

There’s a guide for the new knime expressions language used by Expressions Node (not Column Expressions):

https://docs.knime.com/latest/knime_expressions_guide/index.html#_introduction

For rule engine there are some good videos:

For column expressions you can in general use JavaScript on top of the pre-built functions.

3 Likes

@MartinDDDD thanks a lot for the resources!!

1 Like

Hey look it’s @kowisoft ! :slight_smile:

2 Likes

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