Expression Transformation
Last updated
Last updated
© Copyright 2023, Astera Software
Expression Transformation defines an expression that can be used to process the incoming value (or values) according to the expression’s logic. Expression Transformation can also provide values that do not depend on any user-provided input data and also modify and use variables for various calculations.
Expression Transformation uses an expression which is the logic for transforming data. Expressions can use functions and operations to fields to manipulate data. There are a lot of built-in functions for expressions to use such as string manipulations, data conversions, date and time manipulations, etc. Operations such as calculation, comparison, assignments, etc, are also available. The list of functions can be found on the Expression Builder. Expressions use the Astera Rules Language.
To add an Expression transformation, drag the Expression object from the Transformations group in the Flow toolbox and drop it on the dataflow.
An example of what an Expression transformation object might look like is shown below.
To configure the properties of an Expression object after it was added to the dataflow, right-click on it and select Properties from the context menu. The following properties are available:
Layout Builder screen: Fields can be added to the Layout Builder and can be configured by the following:
Name - The name of the Field
Data Type - The type of data the field is. Different expressions can be made based on what the data type of the field is.
Input - The field can be mapped as an input.
Output - The field can be mapped as output. If an expression is present, the expression is applied to the output.
Variable - Turns the field into a variable which can then be used on other fields. These expressions are calculated first and then assigned to other expressions that use them, no matter what the ordering of the fields is. Once a field turns into a variable, it cannot be configured for input and output mapping.
Expression - The expression used for modifying the field or fields.
The order of expression operations is as follows: Input –> Variable –> Output. They are also applied in a top-to-bottom order. It is recommended to use temporary fields as Variable fields to store data to be used in Output expressions.
Click on the Expression area of the field to add an expression. You can type in the expression directly, or use the Expression Builder by clicking on the properties button.
The Expression Builder provides the interface to help you create your expression.
The sample screenshots above show an expression that builds an address string from the fields: Name, Street, State, and Zip. This example shows string concatenation with different string fields with the use of the plus(+) symbol.
Another use for the Expression transformation is to combine two or more function transformations into one single expression transformation.
In this example, the Expression Transformation named ProperCase performs the same transformation as the two functions: ToLower and ToProper. They convert the string into lowercase and then perform a proper case transformation.
Fields can be converted into variables to be used in other fields.
In this example, the CurrentHour field stores the value from the Hour(Now()) function which takes the current hour of the current date. IsHappyHour then outputs true if the CurrentHour is between 5:00 pm and 6:00 pm.
The advantage of having the variable property checked is even when the order of the fields is swapped (e.g. IsHappyHour comes before CurrentHour), CurrentHour is still calculated first and assigned to the value that is used in IsHappyHour.