Add an Aggregator transformation to the mapping and configure dynamic ports to receive any new and changed columns from the Joiner transformation. Create an aggregate expression to calculate the total price of customer orders and group the aggregation by customer.
Add an Aggregator transformation Agg_CustomerOrders to the mapping.
Create dynamic ports in the Aggregator transformation:
From the Output group in the Joiner transformation, drag the From_Read_CUSTOMER dynamic port to the Aggregator transformation.
A dynamic port From_Read_CUSTOMER appears in the Aggregator transformation.
From the From_Read_ORDERS dynamic port of the Output group in the Joiner transformation, drag the O_TOTALPRICE_DTL generated port to the Aggregator transformation.
The following image shows the ports from the Joiner transformation linked to the Aggregator transformation:
In the
Properties
view, click the
Ports
tab.
Click the
New
button to create a port to aggregate prices of the orders.
The Developer tool creates a new port called Field.
Select the new port, and change the column values as follows:
Name: O_TOTALAMOUNT
Type: decimal
Precision: 10
Scale: 2
Input: Clear the selection to make this port an output-only port.
The following image shows the ports in the Aggregator transformation:
In the Expression column for the O_TOTALAMOUNT port, click the
Open
button.
The
Aggregator Expression
window appears.
Replace the existing expression in the editor with the following expression:
SUM(O_TOTALPRICE_DTL)
Click
Validate
to validate the expression.
Click
OK
.
Click
OK
to exit the
Aggregator Expression
editor.
In the
Properties
view, click the
Group By
tab.
Specify the group by port to aggregate the total price by market segment as follows:
Make sure that
Value
from the
Specify by
list is selected.
Click
Choose
.
The
Ports
dialog box appears.
Select the checkbox next to C_CUSTKEY and click
OK
.
The following image shows the selected group by port:
You can preview the Aggregator transformation data to make sure that it contains the expected results. In the mapping editor, right-click the Aggregator transformation and select
Run Data Viewer
. The data calculated by the transformation appears in the