Using the Expressions Console

The Expressions console is used to enter math expressions to be evaluated by the Math stage. The Input, Calculator, and Functions controls are used to insert values into this console. You can also manually type expressions into the console. Expressions take the form of a constant, variable, or math operation, and consist of numeric constants and variables. Numeric constants are whole or decimal numbers, which can be signed. Variables represent data from the incoming row; for example, if fields x, y, and z are defined in the input, then x, y, and z can be used in an expression. Variables are replaced with field values at runtime.

The Math stage also allows grouped expressions, which involve using parentheses to group expressions and override operator precedence. For example, 2*5^2 equals 50, while (2*5)^2 equals 100.

Note: Every expression you enter must end with a semi-colon.

Additionally, conditional statements can be used in the Expressions console to take actions depending on whether various conditions evaluate to true or false. See Using Conditional Statements for more information on conditional statements.

The Math stage deals primarily with assignment expressions, in which the output from an expression is assigned to a variable. Multiple assignment operations are supported in the stage and can use the output of a previous assignment operation.

Assignment Expression Examples

In the scenario below, x=10 and z=1000:
x=5+5
z=x*100

In the scenario below, the area of a polygon is calculated based on the length of one side and the number of sides.

AreaOfPolygon=
     ((SideLength^2)*NumberOfSides)/
     (4*Tan(pi/NumberOfSides));