You are on page 1of 3

Expression Transformation Overview

Transformation type:
Passive
Connected

Use the Expression transformation to calculate values in a single row. For


example, you might need to adjust employee salaries, concatenate first and last
names, or convert strings to numbers. You can also use the Expression
transformation to test conditional statements before you pass the results to a
target or other transformations.

Use the Expression transformation to perform non-aggregate calculations. To


perform calculations involving multiple rows, such as sums or averages, use the
Aggregator transformation.

Figure 5-1 shows a simple mapping with an Expression transformation used to


concatenate the first and last names of employees from the EMPLOYEES table:
Expression Transformation Components

You can create an Expression transformation in the Transformation Developer or


the Mapping Designer.

An Expression transformation contains the following tabs:

Transformation. Enter the name and description of the transformation. The


naming convention for an Expression transformation is
EXP_TransformationName. You can also make the transformation reusable.
Ports. Create and configure ports.
Properties. Configure the tracing level to determine the amount of transaction
detail reported in the session log file.
Metadata Extensions. Specify the extension name, datatype, precision, and
value. You can also create reusable metadata extensions.

Configuring Ports

You can create and modify ports on the Ports tab.

Configure the following components on the Ports tab:

Port name. Name of the port.


Datatype, precision, and scale. Configure the datatype and set the precision
and scale for each port.
Port type. A port can be input, output, input/output, or variable. The input ports
receive data and output ports pass data. The input/output ports pass data
unchanged. Variable ports store data temporarily and can store values across
the rows.
Expression. Use the Expression Editor to enter expressions. Expressions use
the transformation language, which includes SQL-like functions, to perform
calculations.
Default values and description. Set default value for ports and add
description.

Calculating Values

To calculate values for a single row using the Expression transformation, you must
include the following ports:

Input or input/output ports. Provides values used in a calculation. For


example, if you need to calculate the total price for an order, create two input or
input/output ports. One port provides the unit price and the other provides the
quantity ordered.
Output ports. Provides the return value of the expression. You enter the
expression as a configuration option for the output port. You can also configure
a default value for each port.

You can enter multiple expressions in a single Expression transformation by


creating an expression for each output port. For example, you might want to
calculate different types of withholding taxes from each employee paycheck,
such as local and federal income tax, Social Security and Medicare. Since all of
these calculations require the employee salary, the withholding category, and
may require the corresponding tax rate, you can create input/output ports for the
salary and withholding category and a separate output port for each calculation.

Creating an Expression Transformation

Use the following procedure to create an Expression transformation.

To create an Expression transformation:

1.In the Mapping Designer, open a mapping.


2.Click Transformation > Create. Select Expression transformation.
3.Enter a name and click Done.
Select and drag the ports from the source qualifier or other transformations to
4.add to the Expression transformation.
You can also open the transformation and create ports manually.
Double-click on the title bar and click on Ports tab. You can create output and
5.variable ports within the transformation.
In the Expression section of an output or variable port, open the Expression
6.Editor.
7.Enter an expression. Click Validate to verify the expression syntax.
8.Click OK.
Assign the port datatype, precision, and scale to match the expression return
9. value.
10.Create reusable transformations on the Transformation tab.

Note: After you make the transformation reusable, you cannot copy ports from
the source qualifier or other transformations. You can create ports manually within
the transformation.

11.Configure the tracing level on the Properties tab.


12.Add metadata extensions on the Metadata Extensions tab.
13.Click OK.
14.Connect the output ports to a downstream transformation or target.

You might also like