PXP_Mo
January 19, 2023, 7:12am
1
Hello everyone,
i have following code, i would like use it in a node maybe “Math Formula” :
if a> 53:
a = a + 26
else :
a = a - 53
Thanks
ipazin
January 19, 2023, 7:22am
2
Hello @PXP_Mo ,
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:
Hi all,
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
else
b
may someone help me to understand which node is better to use?
thank you in advance.
simone
Br,
Ivan
4 Likes
PXP_Mo
January 19, 2023, 7:45am
3
Hi Ivan,
Thanks but i can"t Find the solution there.
Hi @PXP_Mo and welcome to the KNIME forum community,
Complementary to @ipazin link, please find below other links sorted by importance that might answer your question:
Hi @rizky_kahfie
There is an If-Condition “if (cond, trueval, falseval)” instruction in the -math Formula- node which allows to do a conditional operation:
[image]
The instruction to write in your case would be:
$Column A$ * if( $$ROWINDEX$$ < 10, 2, 3)
Hope this helps.
Regards
Ael
Hi @kanishka271
Following @Daniel_Weikert ’s trick, you will find below a solution that takes into account your other requirements too:
[image]
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$$),
$$CURRENT_COLUMN$$)
Hope it helps.
Best
Ael
Hi @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.
Best,
Ael
3 Likes
@ipazin 's answer (second post) in the link he shared
br
1 Like
system
Closed
April 19, 2023, 6:02pm
6
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.