Mathematical operations on columns of two tables

Hi

I am new to Knime and I need a help.

I am developing a custom node where I need to do mathematical operations on values of 2 columns of 2 different tables.

For example, if I have 3 columns in Table1(C1,C2,C3) and two columns in Table 2(D1,D2), I need to do ((C3+D2)*100)=50. If this is true, then data of Table1 complying to this will be written in a new table which is the output.

Thanx in advance.

Is making a new node essential to your needs. You could easily do this with existing nodes.

combine the tables with joiner node.

then use maths formula node with your formula. Use the IF operator to specify a 1 or 0 as a result for whether it equals 50 or not.

then row filter on this result column for when output is 1.

then use reference row filter of this table as reference versus table1 for inclusion. You are now left with table1 results which matched your criteria.

simon.

Hi Simon

Yes, making a new node is required because apart from this, I have other requirements also in the node. Can you tell me how can I get the source code of Math node?

Download the KNIME SDK and update the KNIME SDK via the update site including the sources for the Math node. Create a new plug-in via New > New KNIME node extension and make sure you have an dependency defined in the plugin.xml to the Math node. For further details on how develop your own nodes, see our developer guide.

Hi there

Can you please help with a code snippet as to how can I add/divide/subtract/multiply two DataValues?

I am unable to write a function that can add two DataCells/DataValues in order to develop my custom node. Is there any existing method to do the same?

For example, if I have 3 columns in Table1(C1,C2,C3) and two columns in Table 2(D1,D2), I need to do ((C3/D2)*100)>50

I have by far fetched the DataCells of the required columns. But dont know how to progress with the mathematical operations on them.

May be its silly to ask, but I really need the help.

You need to cast the DataCells to the correct value interface, e.g. DoubleValue or IntValue. Then you can retrieve the primitive type using e.g. getDoubleValue or getIntValue and perform any mathematical operation.