Now that you have calculated the highest, lowest, and average prices for items, the next step is to calculate the average profitability of items from each manufacturer.
To add this information to the target, you create an Expression transformation that takes the average price of items from a manufacturer, performs the calculation, and then passes the result along to the target. As you develop transformations, you connect transformations using the output of one transformation as an input for others.
Click
Transformation
Create
.
Select
Expression
and name the transformation EXP_AvgProfit. Click
Create
, and then click
Done
.
The naming convention for Expression transformations is EXP_
TransformationName
.
The Mapping Designer adds an Expression transformation to the mapping.
Right-click on the source definition and source qualifier and select
Iconize
to iconize them.
Open the Expression transformation.
Add an input port, IN_AVG_PRICE, using the Decimal datatype with precision of 19 and scale of 2.
Add an output port, OUT_AVG_PROFIT, using the Decimal datatype with precision of 19 and scale of 2. Clear the Input port.
OUT_AVG_PROFIT is an output port, not an input/output port. You cannot enter expressions in input/output ports.
Enter the following expression for OUT_AVG_PROFIT:
IN_AVG_PRICE * 0.2
To validate the expression, click Validate.
To reflect the latest changes from the expression condition in the test expression section in the right pane, click Refresh.
In the right pane, enter sample values for the input ports used within the expression, and click Evaluate.
Close the
Expression Editor
and then close the EXP_AvgProfit transformation.
Connect OUT_AVG_PRICE from the Aggregator to IN_AVG_PRICE input port.
The following mapping shows a link from the Aggregator transformation port OUT_AVG_PRICE to the input port IN_AVG_PRICE:
Connect the OUT_AVG_PROFIT port in the Expression Transformation to the AVG_PROFIT port in the T_ITEM_SUMMARY target definition.