Thuy Phan Business Intelligence Porfolio

  • 896 views
Uploaded on

 

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads

Views

Total Views
896
On Slideshare
0
From Embeds
0
Number of Embeds
0

Actions

Shares
Downloads
0
Comments
0
Likes
0

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. Project Overview…………………………………………………………….. .1 T-SQL Sample ……………………………………………………………… . 2 MDX queries Samples………………………………………………………...9 SSIS – Integration Services…………………………………………………15 SSAS- Analysis Services…………………………………………………….21 MOSS/PPS- SharePoint and Performance Point Services……………… 30 Thuy Tran Phan 2009 Business Intelligence Portfolio Page 1 of 33
  • 2. Sample Business Intelligence Project Work This portfolio contains selected examples of my works in the Microsoft Business Intelligence. Technologies:  Microsoft SQL Server 2005 T-SQL  Microsoft SQL Server 2005 MDX Query  Microsoft SQL Server 2005 Integration Services –SSIS  Microsoft SQL Server 2005 Analysis Services -SSAS  Microsoft SQL Server 2005 Reporting Services -SSRS  Microsoft Office SharePoint Server 2007 -MOSS  Microsoft Office Perfomance Point Server –PPS Project Specifications: Design, build and deliver a Business Intelligence solution for a construction company to monitor employees, customers, job orders, and timesheets from end- to-end. Project deliverables:  Define a star schema using Visio: 4 facts tables  Create staging database (Visio create the DDL)  Using SSIS design an ETL workflow to update the SQL Server database from Excel files sources.  Using SSAS to design a Star Schema Analysis Services Cube.  Code MDX queries  Using SSAS to define Calculated Members and business Key Performance Indicators – KPI.  Using Excel 2007 to display cube data, KPI, goal, trends, statuses.  Using SSRS to display various summary reports (chart, pie)  Using Microsoft Performance Point to create score cards.  Using MOSS 2007 (SharePoint) to implement business intelligence dashboard. Thuy Tran Phan 2009 Business Intelligence Portfolio Page 2 of 33
  • 3. PART 1: T- SQL 1. Using Sub-query and variables Codes: USE pubs SELECT title, price ,(SELECT AVG(price) FROM titles ) AS average ,price-(SELECT AVG(price) FROM titles) AS difference FROM titles WHERE type='popular_comp' ResultSets: 2. Using variables Codes: DECLARE @AvgPrice DECIMAL(14,4) set @AvgPrice = (SELECT AVG(price) FROM titles ) SELECT title, price, @AvgPRice AS average ,price- @AvgPrice AS difference FROM titles WHERE type='popular_comp' Results: Thuy Tran Phan 2009 Business Intelligence Portfolio Page 3 of 33
  • 4. 3. Using topn function Codes: use northwind declare @TopN int set @TopN = 10 SELECT TOP (@TopN) with ties orderid, productid, quantity FROM [order details] ORDER BY quantity desc Resultset: Thuy Tran Phan 2009 Business Intelligence Portfolio Page 4 of 33
  • 5. 4. Using Top n% function Codes: select top 15 percent OrderID, ProductID, (UnitPrice * Quantity) as ExtendedAmount from [order details] order by ExtendedAmount Desc Results: Thuy Tran Phan 2009 Business Intelligence Portfolio Page 5 of 33
  • 6. 5. Join tables Codes: use library select (a.firstname + '' + a.middleinitial +' '+ a.lastname) as name, b.street, b.city,b.state, b.zip from member as a join adult as b on a.member_no = b.member_no where a.member_no = b.member_no go Resutls Thuy Tran Phan 2009 Business Intelligence Portfolio Page 6 of 33
  • 7. 6. Using rank() function Codes: select top 10 orderid , rank () over (order by freight desc) as RankingNumber, c.companyname, o.freight as freight from orders as o join customers as c on o.customerid = c.customerid order by freight desc Resutls: Thuy Tran Phan 2009 Business Intelligence Portfolio Page 7 of 33
  • 8. 7. Subquery, group by Codes: USE Library SELECT t.title_no, title, l.isbn ,count(*) AS 'Total Reserved' FROM title AS t INNER JOIN loan AS l ON t.title_no = l.title_no INNER JOIN reservation AS r ON r.isbn = l.isbn WHERE r.isbn IN ( SELECT isbn FROM reservation GROUP BY isbn HAVING COUNT(*)> 50 ) AND l.copy_no < 5 GROUP BY t.title_no, title, l.isbn GO Results: Thuy Tran Phan 2009 Business Intelligence Portfolio Page 8 of 33
  • 9. PART 2: MDX QUERIES 1. Query 1-8 Retrieve and calculate the total costs, the total profit, and total profit %, for each individual job. FORMAT AS PERCENT,including the [All] members, alphabetical order of job description Codes: with member [Total Profit] as [Measures].[Total Labor Profit] +[Measures].[Additional Labor Profit] ,format_string = 'currency' member [Profit Pct] as iif( ([total cost] + [total profit]), [Total Profit]/([total cost] + [total profit]),null) ,format_string = "#.00%;;;N/A" member [Total Cost] as ( [Measures].[Total Labor Cost] + [Measures].[Total Material Cost] + [Measures].[Total Overhead]) ,format_string = 'currency' select non empty {[Total Cost],[Total Profit],[Profit Pct]} on columns, --non empty ([Job Master].[Description].members) on rows FROM [Allworks] Results: Thuy Tran Phan 2009 Business Intelligence Portfolio Page 9 of 33
  • 10. 2. Query 1-11 Retrieve all Clients with a Total Labor cost to date greater than 5000, and the word 'INC' appears in the client name in alphabetical order. Codes: with set [Filter Clients] as Filter ( [Job Master].[Client Name].members, ([IncName] and [5000 Labor Cost]) ) member [5000 Labor Cost] as ([Measures].[Total Labor] > 5000) member [IncName] as (instr ([Job Master].[Client Name].currentmember.Name, "INC") >0) member [Total_ LaborCost] as ( [Measures].[Total Labor Cost] + [Measures].[Total Material Cost] + [Measures].[Total Overhead]) ,format_string = 'currency' select [Total_ LaborCost] on columns, [Filter Clients] on rows from [AllWorks] Results: Thuy Tran Phan 2009 Business Intelligence Portfolio Page 10 of 33
  • 11. 3. Using Generate () function Query 4-4: For 2005, show the job and the top three employees who worked the most hours on that job. Show the jobs in alphabetical order and for each job show the employees in hours worked order. Codes: with set [Job] as ([Job Master].[Description].[All].Children, [Measures].[Hoursworked]) set [MainSet] as generate ( [Job], ([Job Master].[Description].currentmember, TopCount ([Employees].[Full Name].children,3, [Measures].[Hoursworked] ) ) ) select [Measures].[Hoursworked] on columns, non empty [MainSet] on rows from [AllWorks] where [All Works Calendar].[Fy Year].[2005] Thuy Tran Phan 2009 Business Intelligence Portfolio Page 11 of 33
  • 12. Results: 4. Using order () function Query 4-2: sort the employees by labor rate descending, sot that the employees with the highest labor rate at the top. Codes: with member [Labor Rate] as iif ([Measures].[Hoursworked], [Measures].[Total Labor] /[Measures].[Hoursworked],null), format_string = "$#.00;;;N/A" select non empty {[Measures].[Hoursworked], [Measures].[Total Labor],[Labor Rate]} on columns, non empty order ( [Employees].[Full Name].[All].children,[Labor Rate],desc) on rows from [AllWorks] where [All Works Calendar].[2005] Result: Thuy Tran Phan 2009 Business Intelligence Portfolio Page 12 of 33
  • 13. 5. Using lag(), currentmember Query 4-5: Show All employees for 2005 Q4, and four periods ago, for total hours worked in the Quarter, alphabetical order, Display NULLS as 0. Codes: with member [2005 Q4] as ([All Works Calendar].[Fy Qtr].currentmember, [Measures].[Hoursworked]), format_string = "#.00;;;0" member [2004 Q4] as ([All Works Calendar].[Fy Qtr].currentmember.lag(4), [Measures].[Hoursworked]), format_string = "#.00;;;0" select {[2004 Q4], [2005 Q4]} on columns, [Employees].[Full Name].children on rows from [AllWorks] Thuy Tran Phan 2009 Business Intelligence Portfolio Page 13 of 33
  • 14. where [All Works Calendar].[Fy Qtr].[2005 Q4] Result: Thuy Tran Phan 2009 Business Intelligence Portfolio Page 14 of 33
  • 15. PART 3: SSIS 1. SSIS package control flow to read data from flat files in a folder. New and update rows are insert in SQL Server database tables. Invalid rows are written out to an error log files. Success and failure emails are sent to users. Control Flow: Thuy Tran Phan 2009 Business Intelligence Portfolio Page 15 of 33
  • 16. DataFlow: This process is repeating for each flat file in the source directory Thuy Tran Phan 2009 Business Intelligence Portfolio Page 16 of 33
  • 17. 2. Master Package: Control Flow: Thuy Tran Phan 2009 Business Intelligence Portfolio Page 17 of 33
  • 18. DataFlow of the Master Package: This is the master package that load the Staging database. After data is loaded, maintenance tasks are performed. Database is re-indexed, backup, shrink. SQL server Agent is set up to run this package at mid night Part 3: Custom VB script to count the row for successful and unsuccessful insert and update. Imports System Imports System.Data Imports System.Math Imports Microsoft.SqlServer.Dts.Runtime Public Class ScriptMain Public Sub Main() Thuy Tran Phan 2009 Business Intelligence Portfolio Page 18 of 33
  • 19. Dim InvalidEmpIDCounts As Integer = CInt(Dts.Variables("InvalidEmpIDCounts").Value) Dim InvalidJobIdCounts As Integer = CInt(Dts.Variables("InvalidJobIdCounts").Value) Dim JobTimeSheetJobClosed As Integer = CInt(Dts.Variables("JobTimeSheetJobClosed").Value) Dim JobTimeSheetNewRows As Integer = CInt(Dts.Variables("JobTimeSheetNewRows").Value) Dim JobTimeSheetUpdateRows As Integer = CInt(Dts.Variables("jobTimeSheetUpdateRows").Value) Dim TotalInvalidEmpIdCount As Integer = _ CInt(Dts.Variables("TotalInvalidEmpIdCounts").Value) Dim TotalInvalidJobIdCount As Integer = _ CInt(Dts.Variables("TotalInvalidJobIDCounts").Value) Dim TotalJobTimeSheetJobClose As Integer = _ CInt(Dts.Variables("TotalJobTimeSheetJobClose").Value) Dim TotalJobTimeSheetNewRows As Integer = _ CInt(Dts.Variables("TotalJobTimeSheetNewRows").Value) Dim TotalJobTimeSheetUpdateRows As Integer = _ CInt(Dts.Variables("TotalJobTimeSheetUpdateRows").Value) Dts.Variables("TotalInvalidEmpIdCounts").Value = InvalidEmpIDCounts + TotalInvalidEmpIdCount Dts.Variables("TotalInvalidJobIDCounts").Value = InvalidJobIdCounts + TotalInvalidJobIdCount Dts.Variables("TotalJobTimeSheetJobClose").Value = JobTimeSheetJobClosed + TotalJobTimeSheetJobClose Dts.Variables("TotalJobTimeSheetNewRows").Value = JobTimeSheetNewRows + TotalJobTimeSheetNewRows Dts.Variables("TotalJobTimeSheetUpdateRows").Value = JobTimeSheetUpdateRows + TotalJobTimeSheetUpdateRows Dts.TaskResult = Dts.Results.Success End Sub End Class Thuy Tran Phan 2009 Business Intelligence Portfolio Page 19 of 33
  • 20. 3. Notification: This is an example of the settings to send email alert upon completion. Statistical counts are sent to users. Email: Thuy Tran Phan 2009 Business Intelligence Portfolio Page 20 of 33
  • 21. SSAS- Cube Data  Restore AllWorks Database from a backup file.  Create 4 facts tables: Job Summary, Job Overhead, Job Material and Job Labor.  Create AllWorks Calendar.  Create relationship between tables.  Use “Service Account” for Login Credential.  Select fact tables and dimension tables. AllWork Database Schema- DataSource view in BIDS- Thuy Tran Phan 2009 Business Intelligence Portfolio Page 21 of 33
  • 22. [AllWorks] CUBE in Design mode in BIDS  Build AllWorks cube using Cube Wizard  Created hierarchy and attributes.  Correctly identified 4 facts tables and dimensions. This is very important since all calculations are base on these.  Verified measures by measures group.  Verified dimensions.  Name the cube.  Use Dimension Usage to verify dimensions used in each fact table.  Rename levels and create hierarchy Allworks Calendar dimension Thuy Tran Phan 2009 Business Intelligence Portfolio Page 22 of 33
  • 23. KPI screen shots: 1. Open Receivables Percent KPI Calculate Member: iif([Measures].[Invoice Amount], ([Measures].[Invoice Amount]-[Measures].[Amount Received])/ [Measures].[Invoice Amount], -1) When Statement: -Open A/R Percentage---. --Less than goal is good. Between goal & double is warning--- case When KPIValue("Open Receivable KPI")<= .10 then 1 --- Green Status When KPIValue("Open Receivable KPI") >= .10 and KPIValue("Open Receivable KPI") < .20 then 0 --- Yellow Status Else -1 --- Red Status End Thuy Tran Phan 2009 Business Intelligence Portfolio Page 23 of 33
  • 24. Excel Screen Shot: Open Receivable Percentage. This report in Excel 2007 shows clients and their Open Receivable Percent. KPI Interpretation: KPI Goal is 10% or .10  Green Status: Less or Equal to 10% is good.  Yellow Status: between 10 and 20% is warning.  Red Status: Equal or greater than 20% is bad Thuy Tran Phan 2009 Business Intelligence Portfolio Page 24 of 33
  • 25. 2. Job Increase KPI Calculate Member ([All Works Calendar].[Fy Qtr].currentmember, [Measures].[Job Summary Facts Count])- ([All Works Calendar].[Fy Qtr].prevmember, [Measures].[Job Summary Facts Count]) Excel Screen Shot When Statement -- stautus 0 or more is good meaning we have the same # of job --anything less than 0 is bad case When KPIValue("JobIncrease KPI")>= 0 then 1 --- Green Status else -1 -------REd status End Thuy Tran Phan 2009 Business Intelligence Portfolio Page 25 of 33
  • 26. 3.Profit Percent KPI Calculate Member:  Total Cost:( [Measures].[Total Labor Cost] + [Measures].[Total Material Cost] + [Measures].[Total Overhead])  Total Profit: [Measures].[Total Labor Profit] +[Measures].[Total Material Profit] +[Measures].[Additional Labor Profit]  Profit percent: iif( ([total cost] + [total profit]), [Total Profit]/([total cost] + [total profit]),1) Excel Screen Shot: When Statement: case When KPIValue("Profit PercentKPI")>= .15 then 1 --- Green Status When KPIValue("Profit PercentKPI") > .05 then 0 --- Yellow Status else -1 --- Red Status Thuy Tran Phan 2009 Business Intelligence Portfolio Page 26 of 33
  • 27. 4. Overhead Percentage from Period to Period KPI Calculated Members:  Overhead Current Member: ([All Works Calendar].[Fy Qtr].currentmember,[Measures].[Weekly Over Head])  Overhead Previous Member: ([All Works Calendar].[Fy Qtr].prevmember,[Measures].[Weekly Over Head])  Overhead Percent Period to Period: iif([Overhead PrevMem], ([Overhead CurrentMem] - [overhead PrevMem]) /[Overhead PrevMem],1) KPI Screen Shot Thuy Tran Phan 2009 Business Intelligence Portfolio Page 27 of 33
  • 28. Excel Screen Shot of Overhead Percentage from Period to Period KPI When statement: -Less than goal is good. Between goal & double is warning--- case When KPIValue("Overhead Pct PD to PD KPI")< .10 then 1 --- Green Status When KPIValue("Overhead Pct PD to PD KPI") <= .15 then 0 --- Yellow Status Else -1 --- Red Status End Thuy Tran Phan 2009 Business Intelligence Portfolio Page 28 of 33
  • 29. Cube Partition Thuy Tran Phan 2009 Business Intelligence Portfolio Page 29 of 33
  • 30. MOSS/PPS- Share Point and Perfomance Point Services ScoreCards created in PPs Custome MDX queries to select top 10 jobs and top 5 employee: 1. Top 10: with member [totalLabor] as[Measures].[Total Labor], format_string = 'currency' SELECT {[Measures].[Hoursworked], [totalLabor] } ON COLUMNS, topcount ({ [Job Master].[Description].[Description].ALLMEMBERS }, 10, [Measures].[Total Labor] ) ON ROWS FROM [Project Labor Cube] where (<<QuarterFilter>>) QuarterFilter: [Project Labor View].[FY Qtr].currentmember Thuy Tran Phan 2009 Business Intelligence Portfolio Page 30 of 33
  • 31. 2. Top 5 employee: with member [totalLabor] as[Measures].[Total Labor], format_string = 'currency' SELECT {[Measures].[Hoursworked],[totalLabor]} ON COLUMNS, TopCount ({ [Employees].[Full Name].[Full Name].ALLMEMBERS }, 5, [totalLabor]) ON ROWS FROM [Project Labor Cube] where <<Labor Quarter>> 3. Percent of Total Dollars with member [Sum_of_Total_Labor] as Sum([Employees].[Full Name].siblings, [Measures].[Total Labor]) , format_string = 'currency' member [percent_of_total] as [Measures].[Total Labor]/[Sum_of_Total_Labor], format_string = 'percent' SELECT {[Measures].[Total Labor], [Sum_of_Total_Labor], [percent_of_total]} ON COLUMNS, Non Empty ( { [Job Master].[Description].[Description].ALLMEMBERS } ) ON ROWS FROM [Project Labor Cube] WHERE <<EmployeeParameter>> Thuy Tran Phan 2009 Business Intelligence Portfolio Page 31 of 33
  • 32. Graph, chart and report in SharePoint Labor Analysis Graph and Labor Dollar Percentage Report by Employee Thuy Tran Phan 2009 Business Intelligence Portfolio Page 32 of 33
  • 33. Profit Labor Rpt in SharePoint Thuy Tran Phan 2009 Business Intelligence Portfolio Page 33 of 33