"Data access mode" listbox and pick 'Source Data$' as Name of the Excel sheet. Switchto the Column section within the Editor window and mark Country, Salesperson, OrderDate, and Order Amount in the Available External Columns listing. Once you completethese steps, click on the OK button to close the Editor window.Next, drag Derived Column transform from the Toolbox and connect the output of ourExcel Source with its input. Launch its Editor window and define a new derived columnnamed Order Year, calculated using the
expression (set its datatype to two byte unsigned integer). Accept the changes by clicking on the OK button.Once back to the Data Task tab, add Aggregate transform to the Data Flow task areaand drag the green arrow originating from the Derived Column to its input. On theAggregation tab of its Editor window, select Country, Salesperson, Order Year andOrder Amount in the Available Input Columns box and ensure that the first three arelisted with "Group by" operation and the last one has "Sum" applied to it. Close theEditor window and return to the Data Flow task tab.Next transformation that needs to be included in our package is Pivot. Once you havedropped it onto the Data Flow area from the Toolbox, connect the output of Aggregateto its input and select Edit or Show Advanced Editor - interestingly both present youwith the same Advanced Editor for Pivot window. Once there, review the ComponentProperties tab and switch to the Input Columns tab. Ensure that all available inputcolumns (Salesperson, Order Amount, Country, and Order Year) are selected andswitch to the Input and Output Properties. This is where the majority of configurationtakes place.As mentioned before, our goal is to display the outcome in the specific format, withthree extra columns (2003 Orders Amount, 2004 Orders Amount, and 2005 OrdersAmount), in addition to the two original ones - Salesperson and Country. With theassistance of Derived Column and Aggregate, we have so far managed to create arecordset with Salesperson, Country, Order Year, and Order Amount fields, whichcontains the total amount of orders for a specific salesperson in a given year, giving us27 rows (9 salespeople times 3 years) - down from 799 rows in theSampleSalespersonReports.xls spreadsheet. At this point, we want to rearrangerecords in such way that instead of Order Year and Order Amount columns, we willhave three columns, one per each year covered by our sales inventory (giving us atable with 9 rows and 5 columns - with a single row for each salesperson) listing theamount of sales for an individual salesperson in that year. According to pivotnomenclature, Salesperson and Country function as SetKeys (values in these inputcolumns identify records that need to be grouped together in the same output row),Order Year serves the role of the PivotKey (column which values are used to determineadditional columns in the resulting recordset), and Order Amount containsPivotedValues (which are copied to the new columns created by pivot). Keep in mindthat entries in SetKey and PivotKey columns have to be unique on the per-row basis(which is the case, since the data has been aggregated prior to applying the pivot).Continue our configuration by expanding the Pivot Default Input node, which lists allinput columns. For each, you need to define its role in the pivot process, by setting thePivotUsage custom property, which can take on one of the following values:
0 - indicates that content of the column is simply copied to the output,
1 - designates column participating in KeySet (this value should be assigned forSalesperson and Country),
2 - identifies the PivotKey column (Order Year in our case),
3 - intended for PivotedValues (Order Amount).