Hi all,
I need to execute an If-else condition as follows -
if(valueofcell==“Fault”)
{if(valueofcell2 ==“Reason”)
{
display valueofcell2;
}
elseif(valueofcell3==“Reason”)
display valueof cell3;
… and so forth}
Hey I think you are looking for the rule engine node, there you can specify exactly that, just in an easier Syntax. Otherwise you could always use a Python/Java/R Snippet Node.
Hi Jennifer,
Thanks for the reply.I tried using the Java snippet node but there is no way to access multiple cells in a single code. If i am accessing valueofcell,i cant access valueofcell2 and other cells…
I believe you can do this in a Java snippet. I’ve attached a workflow with some generated data and dummy logic. Also, here’s a screenshot of the dummy logic:
I think you have to clarify what you mean by single cells. Are all cells in a column, or row or just somewhere in your table?
Just like Scott showed you access a column by its name in a snippet. If you need a specific value you can just use indexing of these columns.
Hi if you tell KNIME a column name it will automatically iterate through the whole column and use every single value, at least thats what the rule engine node does. For R and Python the column is just treated as an iterable list, so you can just loop over the values.
In Scotts snippet it looks like the Java is doing that on its own, or he just has one row of values.
See attached workflow, it might help you. The point of this solution is collecting values
from multiple rows into a list, then splitting the list into multiple columns and performing rules
on them.
If I may, I would suggest to use a Lag Column node to implement your solution. Whenever it is possible, I try to minimize the use of loops in workflows because they slow down the speed of workflow execution. Please find attached below the Lag Column Node version. Hope this is of help.