i have following code, i would like use it in a node maybe “Math Formula” :
if a> 53:
a = a + 26
a = a - 53
and welcome to KNIME Community!
If statements can be done within couple of nodes in KNIME. Math Formula is one of them and syntax is pretty straightforward. You have description of
if() function within node itself so take a look and give it a try. Additionally take a look at this topic on if else statements:
i’d like to be able to use IF STATEMENT that allow me to make this formula:
a= 1 column
b= 2 column
c= 3 column
if a > b then d = c * b
may someone help me to understand which node is better to use?
thank you in advance.
Thanks but i can"t Find the solution there.
@PXP_Mo and welcome to the KNIME forum community,
@ipazin link, please find below other links sorted by importance that might answer your question:
There is an If-Condition “if (cond, trueval, falseval)” instruction in the -math Formula- node which allows to do a conditional operation:
The instruction to write in your case would be:
$Column A$ * if( $$ROWINDEX$$ < 10, 2, 3)
Hope this helps.
Following @Daniel_Weikert’s trick, you will find below a solution that takes into account your other requirements too:
The extra added trick here is to use a “if-then-else” condition to avoid dividing the last row too:
if($$ROWINDEX$$ + 1 < $$ROWCOUNT$$,
100 * $$CURRENT_COLUMN$$ / COL_MAX($$CURRENT_COLUMN$$),
Hope it helps.
@tdewagner & welcome to the KNIME community
I guess the difficulty here comes from the list of proposed functions in the -Math Formula- node which does not include the basic mathematical operators “+,-,*,/”.
The -Math Formula- node allows writing a mathematical formula as a combination of functions and basic mathematical operations. Parenthesis “(,)” to prioritize operations are also allowed. As explained in the help, one can also deal with NaN values (or missing values) with the following …
Hope it helps.
@ipazin 's answer (second post) in the link he shared