Math formula. How to pass string value in IF statement

How to pass string value in Math Formula in IF statement?
What am i doing wrong?
if($price$ <= 2500000, “low”, “High”)

1 Like

Welcome to the forum, @SyedZainZaidi

I’d use a Rule Engine or Column Expressions node for this kind of thing, instead of a Math Formula node.

7 Likes

Hi,

I absolutely agree with @elsamuel.

@SyedZainZaidi, please find attached the example workflow with the two solutions, what was proposed by @elsamuel.

Roland

Prices.knar.knwf (8.1 KB)

4 Likes

As other have pointed out you should use a Rule Engine for this but the reason why your example doesn’t work is because nodes in KNIME are usually very specific so a Math expression will only return numbers. You are returning a string from the formula and that won’t work.

1 Like

Hi
Instead of “Low”, “High”, you may just return numbers (0, 1), then convert to string (Number to string node) and replace the strings using a string replacer node.
stefan

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.