pbPassingBI
/
Data manipulation beginner 6 min

The Rule Engine

Conditional logic — the IF/CASE of KNIME.

What you'll be able to do
  • Write rules with correct syntax
  • Append or replace a column
  • Order rules so the right one wins

Syntax

$Revenue$ > 1000 => "High"
$Revenue$ > 100  => "Medium"
TRUE             => "Low"

Column names in $, string values in double quotes, => before the result. Rules evaluate top to bottom and the first match wins, so a TRUE => catch-all belongs last.

Without a catch-all, unmatched rows get a missing value — which is sometimes what you want and is more often an oversight.

Order matters

Put the most specific rule first

$Revenue$ > 100  => "Medium"
$Revenue$ > 1000 => "High"      <- never reached

Every value over 1000 is also over 100, so the first rule catches everything and the second never fires. Order from most specific to least.

Append or replace

The dialog offers appending a new column or replacing an existing one. Appending is safer while developing, since you can compare the original and the result side by side.

Operators

OperatorUse
=, >, <, >=, <=Comparison
LIKEWildcard match, e.g. $Name$ LIKE "Ltd"
MATCHESRegex
INMembership in a list
MISSINGMISSING $Email$ => "No email"
AND, OR, NOTCombine conditions

Rule Engine versus Math Formula versus String Manipulation

Rule Engine for conditional assignment. Math Formula for arithmetic. String Manipulation for text functions such as strip(), upperCase(), substr(), replace().

Where you need arithmetic that varies by condition, Rule Engine can produce a value that Math Formula then uses — or use Column Expressions, which combines both in a scripting-style interface.

Key points
  • Rules evaluate top to bottom; the first match wins
  • Order from most specific to least, and end with a TRUE catch-all
  • Rule Engine for conditions, Math Formula for arithmetic, String Manipulation for text
Check yourself