IF function to deliver string values

Hello all,

I am sorry if my question sounds really basic. I recently use Knime IF function in math formula to return String values if the conditions are fullfiled or not. But apparently the function doesn't recognize my string values since I always have "?" as output.

The expression looks like this:

if($Change%$ >= 1.01 && $Difference$ <= 300,"Buy" ,"Sell" )

Thank you in advance for you help.

Hi DareDevil,

you are right, the math node can only output numerical values.

You need to use the Rule Engine node for this.

Best, Iris

Hi Iris,

the above code you mentioned is not working for me.

could you help me with this.

Regards
pavan kumar

Hi @PavanKumar574 -

Maybe you could post an example of your input data and desired output data in a different thread? Then I’m sure there would be some folks willing to jump in and help.

Try

2 Likes

Hi @daredevil87,
you can use java snippet simple node or java snippet node.

e.g. for java snippet simple node
if($Change%$ >= 1.01 && $Difference$ <= 300) {return “Buy”;}
else {return “Sell”;}

BR

1 Like

Hi
I have the same problem where I am trying to use an IF function to deliver strings.
I tried installing the Column Expressions but it doesn’t support IF functions.
I don’t know java - is there a way I can use an IF function in KNIME without using java?
Thanks

Edit: I found out how to do IF functions and nested IF functions in Column Expressions:
if(state1) {
// do this, if state1 evaluates to true
} else {
if(state2) {
// do this, if state1 evaluates to false and state2 evaluates to true
} else {
// do this if neither state1 nor state2 evaluate to true
}
}

1 Like

Please, formulate logic you need to implement. If perfectly works but has some specifics like equation is == not =.