Upcoming SlideShare
×

# Calculation Package

666 views

Published on

1 Like
Statistics
Notes
• Full Name
Comment goes here.

Are you sure you want to Yes No
• Be the first to comment

Views
Total views
666
On SlideShare
0
From Embeds
0
Number of Embeds
4
Actions
Shares
0
1
0
Likes
1
Embeds 0
No embeds

No notes for slide

### Calculation Package

1. 1. Calculation Package <ul><li>Obejective: </li></ul><ul><li>Will Calculate the total order by product. </li></ul><ul><li>Wil calculate the total average by product. </li></ul><ul><li>Will Calculate The total cost of the product. </li></ul><ul><li>From Database source to Flat file destination </li></ul>
2. 2. Target Outcome: ( SQL code) <ul><li>Use Adventureworks </li></ul><ul><li>Select </li></ul><ul><li>p.ProductID, sum(p.Quantity) as [Quantity Sum], </li></ul><ul><li>Sum(p.Quantity*ActualCost) as [Total Cost], </li></ul><ul><li>avg([t].[Total Cost]/[t].[Quantity Sum]) as [average] </li></ul><ul><li>from </li></ul><ul><li>Production.TransactionHistoryArchive p </li></ul><ul><li>,(Select ProductID, sum(Quantity) as [Quantity Sum], </li></ul><ul><li>Sum(Quantity*ActualCost) as [Total Cost] </li></ul><ul><li>from Production.TransactionHistoryArchive </li></ul><ul><li>group by ProductID) t </li></ul><ul><li>where p.ProductID = t.ProductID </li></ul><ul><li>group by p.ProductID </li></ul><ul><li>order by p.ProductID </li></ul>
3. 3. Target Outcome : (SQL code) Snapshot:
4. 4. Contol Flow
5. 5. Note: Some task are created for testing purposes.
6. 7. Data Flow Calculate values
7. 8. <ul><li>Note : Some transformation are added for testing purposes . </li></ul>
8. 9. Source: OLEDB Destination: dbo.Adventureworks <ul><li>SELECT ProductID,Quantity,ActualCost </li></ul><ul><li>FROM Production.TransactionHistoryArchive </li></ul>
9. 10. Derived Column: Calculate LineItemTotalCost <ul><li>Quantity * ActualCost </li></ul>
10. 11. Aggregate : Sum Quantity and LineItemTotalCost <ul><li>[ProductID] = Group By(ProductID) </li></ul><ul><li>[QuantitySum] = Sum (Quantity) </li></ul><ul><li>[TotalCostById] = Sum(LineItemTotalCost) </li></ul>
11. 12. Derived Column 2: Calculate Average Cost <ul><li>[AvgCostByID] = TotalCostByID / QuantitySum </li></ul>
12. 13. Sort Transformation: Sort by ProductID <ul><li>Order By Product ID Desc </li></ul>
13. 14. Destination: Flat File Destination: Load Data <ul><li>C:DOCUME~1KARLO~1.CAMLOCALS~1Temp </li></ul>
14. 15. Configuration Package This will support the file system task for locating the specific flat file in the hard drive.
15. 16. Destination