Beginner- i want to carry out a case statement to create a new coln how do i do it

i want to replicate something like this in knime how do i do it
CASE
WHEN Salary <= 12570 THEN 0
WHEN Salary <= 20000 THEN (Salary - 12570) * 0.10
WHEN Salary <= 50000 THEN (20000 - 12570) * 0.10 + (Salary - 20000) * 0.20
ELSE (20000 - 12570) * 0.10 + (50000 - 20000) * 0.20 + (Salary - 50000) * 0.30
END AS Tax

You can use for example the new Expressions Node with an if statement:

if($["Salary"] <= 12570, 0, $["Salary"] <= 20000, ($["Salary"] - 12570) * 0.10, $["Salary"] <= 50000, (20000 - 12570) * 0.10 + ($["Salary"] - 20000) * 0.20, (20000 - 12570) * 0.10 + (50000 - 20000) * 0.20 + ($["Salary"] - 50000) * 0.30)

Prototype:
caseExample.knwf (77.4 KB)

Overview:

3 Likes

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