To find the annual sum of quarterly data for each store, you might use a vertical expression macro in an Aggregator transformation.
The Aggregator transformation uses the store ID field as the group by field. A %QuarterlyData% macro input field reads sales data from the following input fields: Q1, Q2, Q3, and Q4.
A %QuarterlyData%_out macro output field is based on the %QuarterlyData% macro input field. To find the sum of sales for each quarter, the macro output field includes the following expression:
SUM(%QuarterlyData%)
.
In the Target transformation, a field rule includes the following output fields in the incoming fields list: Q1_out, Q2_out, Q3_out, Q4_out. In the target field mapping, the Qx_out fields are mapped to the target.
The following image shows the vertical expression macro in an Aggregator transformation:
When the task runs, the expression expands vertically, as follows:
SUM(Q1)
SUM(Q2)
SUM(Q3)
SUM(Q4)
The task groups the data by store when it performs the aggregation and writes the results to the target.