division by condition

Hello I try to do this SPSS code in Knime but I had some issues, I tried different ways, but i<m blocked :

if Client = A then 80/50
elseif Client = B then 50/50
elseif Client = C then 60/50
elseif Client = D then 160/50
elseif Client = E then 80/50
elseif Client = F then 79/50
elseif Client = G then 79/50
elseif (CNT_O > 0 and CNT_P= 0) then CNT_O/100
elseif (CNT_P > 0 and CNT_O = 0) then CNT_P/50
elseif CNT_O > 0 and CNT_P > 0 then CNT_P/75
else 0
endif

Thank you for your help

hi
column expressions or rule engine or rule engine dictionary could be helpful nodes here
br

Hi! I ve tried the rule engine but Knime doesn’t like the / : $THIRD_NR$ = A=> 80/50

Yes because of your division. You either split your flow in more nodes or try column expressions
br

Thank you very much. Could you please explain the next steps? I’ve tried, but I can’t find any solutions. Thanks a lot

The code below should get you started in a Column Expression

if (column("Client").equals("A")) {
    80/50
} elseif (column("Client").equals("B")) {
    50/50
} elseif (column("Client").equals("C")) {
    60/50
} elseif (column("Client").equals("D")) {
    160/50
} elseif (column("Client").equals("E")) {
    80/50
} elseif (column("Client").equals("F") || column("Client").equals("G")) {
    79/50
} elseif (column("CNT_O") > 0 && column("CNT_P") = 0) {
    column("CNT_O") / 100
} elseif (column("CNT_P") > 0 && column("CNT_O") = 0) {
    column("CNT_P") / 50
} elseif (column("CNT_O") > 0 && column("CNT_P") > 0) {
    column("CNT_P") / 75
} else {
    0
}
4 Likes

Thank you ! but i don’t have the column expression node in my Knime version :frowning:

Drag and drop it or install the Expressions extension.

1 Like

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