Need help with IF THEN ELSE

I’m coming from a Tableau background where it’s very straight forward.

IF [CourseCode] = ‘8021’
OR [CourseCode] = ‘8022’
OR [CourseCode] = ‘TRWSH’
OR [CourseCode] = ‘RSWSH’
THEN ‘Yes’ ELSE ‘No’ END

I’m trying to create something like this, what I have found is that I might be utilizing the Rule Engine node. Is this correct? How might I go about this if so?

Appreciate the help.

Hi @jdlueken84

Welcome to the KNIME community!

Indeed, the Rule Engine is an option you could use. For that, set the expression to:

$CourseCode$ = "8021" OR $CourseCode$ = "8022" OR $CourseCode$ = "TRWSH" OR $CourseCode$ = "RSWSH"  => "YES"
TRUE => "NO"

In action:

The last line might read a bit tricky if you are not used to it, but the standard comments in the Rule Engine explain this:

image

Which is equivalent to ELSE.

Hope this helps!

2 Likes

This worked exactly as I needed it, and was very clear in how the syntax is layed out for this. Thank you for the help.

1 Like

One more to add on here. I have another field that is a bit more complex than the previous.

IF {FIXED [SSID]: MAX([CourseCode] = ‘8022M’)}
AND {FIXED [SSID]: MAX([Entity Id] = ‘439’ OR [Entity Id] = ‘442’)}
THEN ‘Yes’ ELSE ‘No’ END

This is looking at that specific class, but also only at 439 and 442 entity. I have others based on this, but having this solved will help me with the others.

Just to be sure, is MAX being used as a descriptive or as a function?

If the former is the case, then it’s pretty much the same as the first one but with an enclosed AND group.

$FIXED [SSID]: MAX([CourseCode]$ = "8022M" AND ($FIXED [SSID]: MAX([Entity Id]$ = "439" OR $Entity Id$ = "442") => "YES"
TRUE => "NO"

It is being used as part of the FIXED function in Tableau.

That I don’t know, I’m a SiSense user :laughing:

No worries, I may be able to figure it out by trial and error. Appreciate the help so far.

Figured it out already, Knime is always looking at row level detail it seems. Where as Tableau you have to tell it you want to look at the row as a whole, hence the FIXED function. So just putting the course code AND entity worked.

$CourseCode$ = "8022M" AND $Entity Id$ = "442" => "YES" TRUE => "NO"

2 Likes

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