Beruflich Dokumente
Kultur Dokumente
SQL Server 2008 R2 1 out of 4 rated this helpful - Rate this topic In this lesson, you will create shared datasets and configure report parameters based on the dataset query parameters for the Employee_Sales_Summary_2008R2 report.
Requirements
For information about requirements, see Prerequisites for AdventureWorks 2008R2 Sample Reports (SSRS). This lesson assumes that you have completed Creating the Report Server Project and the AdventureWorks2008R2_Base Report (SSRS).
Tips
For a list of general tips, see Report Design Tips (Report Builder 3.0 and SSRS).
b. Right-click the project node, and then click Paste. c. Rename the copied report to Employee_Sales_Summary_2008R2.rdl.
Create EmployeeSalesYearOverYear2008R2 To add a shared dataset for year over year sales
1. In Solution Explorer, add a shared dataset named EmployeeSalesYearOverYear2008R2. The data helps answer the question: How do my seasonal sales compare year over year? In the report, the line chart and sparkline chart will display this data. 2. Point to the AdventureWorks2008R2 shared data source and add the following query: 3. SELECT P.FirstName + ' ' + P.LastName AS Employee, 4. DATEPART(Year, SOH.OrderDate) AS [Year], 5. DATEPART(Month, SOH.OrderDate) AS MonthNumber, 6. DATENAME(Month, SOH.OrderDate) AS [Month], 7. SUM(DET.LineTotal) AS Sales 8. FROM [Sales].[SalesPerson] SP 9. INNER JOIN [Sales].[SalesOrderHeader] SOH ON SP.[BusinessEntityID] = SOH.[SalesPersonID] 10. INNER JOIN Sales.SalesOrderDetail DET ON SOH.SalesOrderID = DET.SalesOrderID 11. INNER JOIN [Sales].[SalesTerritory] ST ON SP.[TerritoryID] = ST.[TerritoryID] 12. INNER JOIN [HumanResources].[Employee] E ON SOH.[SalesPersonID] = E.[BusinessEntityID] 13. INNER JOIN [Person].[Person] P ON P.[BusinessEntityID] = SP.[BusinessEntityID] 14. WHERE (DATEPART(Year, SOH.OrderDate) <= @ReportYear - 1 OR 15. DATEPART(Year, SOH.OrderDate) = @ReportYear AND DATEPART(Month, SOH.OrderDate) <= @ReportMonth) AND 16. (SOH.SalesPersonID = (@EmployeeID)) 17. GROUP BY P.FirstName + ' ' + P.LastName, SOH.SalesPersonID, 18. DATEPART(Year, SOH.OrderDate), DATEPART(Month, SOH.OrderDate), 19. DATENAME(Month, SOH.OrderDate) The shared dataset appears in Solution Explorer. 20. In the Report Data pane, create a dataset named EmployeeSalesYearOverYear2008R2. 21. In the Dataset Properties dialog box, select Use a shared dataset, and click the dataset that you just created in Solution Explorer. The dataset query includes query variables @ReportMonth, @ReportYear, and @EmployeeID. 22. In Dataset Properties, verify that a dataset parameter is created for each query variable.
23. In the Report Data pane, verify that a report parameter is created for each dataset parameter. The dataset in the Report Data pane is a reference to the shared dataset in Solution Explorer. After the report is published, the reference points to the shared dataset on the report server or SharePoint site.
Create EmployeeSalesDetail2008R2 To add a shared dataset that includes data for each sales order
1. In Solution Explorer, add a shared dataset named EmployeeSalesDetail2008R2. This data helps answer the question: Am I meeting my sales quotas for the whole month and for each category? In the report, the matrix and embedded indicators will display this data. 2. Use the AdventureWorks2008R2 shared data source and the following query: 3. SELECT PER.FirstName + ' ' + PER.LastName AS Employee, 4. PS.Name AS Subcategory, SUM(DET.LineTotal) AS Sales, 5. SOH.SalesOrderID, SOH.SalesOrderNumber, 6. P.Name AS Product, 7. SUM(DET.OrderQty) AS OrderQty, DET.UnitPrice, 8. PC.Name AS Category 9. FROM Sales.SalesOrderHeader SOH 10. INNER JOIN [Sales].[SalesPerson] SP ON SP.[BusinessEntityID] = SOH.[SalesPersonID] 11. INNER JOIN Sales.SalesOrderDetail DET ON SOH.SalesOrderID = DET.SalesOrderID 12. INNER JOIN [HumanResources].[Employee] E ON SOH.[SalesPersonID] = E.[BusinessEntityID] 13. INNER JOIN [Person].[Person] PER ON PER.[BusinessEntityID] = SP.[BusinessEntityID] 14. INNER JOIN Production.Product P ON DET.ProductID = P.ProductID 15. INNER JOIN Production.ProductSubcategory PS ON P.ProductSubcategoryID = PS.ProductSubcategoryID 16. INNER JOIN Production.ProductCategory PC ON PS.ProductCategoryID = PC.ProductCategoryID 17. WHERE (DATEPART(Year, SOH.OrderDate) = @ReportYear) AND 18. (DATEPART(Month, SOH.OrderDate) = @ReportMonth) AND 19. (SOH.SalesPersonID = @EmployeeID) 20. GROUP BY PER.FirstName + ' ' + PER.LastName, 21. DATEPART(Month, SOH.OrderDate), SOH.SalesOrderID, SOH.SalesOrderNumber, 22. P.Name, PS.Name, DET.UnitPrice, PC.Name The shared dataset appears in Solution Explorer. 23. In the Report Data pane, create a dataset named EmployeeSalesDetail2008R2. 24. In the Dataset Properties dialog box, select Use a shared dataset, and click the dataset that you just created in Solution Explorer.
Create EmpSalesMonth2008R2 To add a shared dataset for month over month sales
1.
In Solution Explorer, add a shared dataset named EmpSalesMonth2008R2. This data helps answer the question: How do the category sales for this month compare to sales for the same month in previous years? In the report, the column chart and a databar chart will display this data.
2. Use the AdventureWorks2008R2 shared data source and the following query: 3. SELECT PER.FirstName + ' ' + PER.LastName AS Employee, 4. DATEPART(Year, SOH.OrderDate) AS [Year], 5. DATEPART(Month, SOH.OrderDate) AS [MonthNumber], 6. DATENAME(Month, SOH.OrderDate) AS [Month], 7. PC.Name AS Category, SUM(DET.LineTotal) AS Sales 8. FROM Sales.SalesOrderHeader SOH 9. INNER JOIN [Sales].[SalesPerson] SP ON SP.[BusinessEntityID] = SOH.[SalesPersonID] 10. INNER JOIN Sales.SalesOrderDetail DET ON SOH.SalesOrderID = DET.SalesOrderID 11. INNER JOIN [HumanResources].[Employee] E ON SOH.[SalesPersonID] = E.[BusinessEntityID] 12. INNER JOIN [Person].[Person] PER ON PER.[BusinessEntityID] = SP.[BusinessEntityID] 13. INNER JOIN Production.Product P ON DET.ProductID = P.ProductID 14. INNER JOIN Production.ProductSubcategory PS ON P.ProductSubcategoryID = PS.ProductSubcategoryID 15. INNER JOIN Production.ProductCategory PC ON PS.ProductCategoryID = PC.ProductCategoryID 16. WHERE 17. (DATEPART(Year, SOH.OrderDate) <= @ReportYear) 18. AND (DATEPART(Month, SOH.OrderDate) = @ReportMonth) 19. AND (SOH.SalesPersonID = @EmployeeID) 20. GROUP BY PER.FirstName + ' ' + PER.LastName, 21. DATEPART(Year, SOH.OrderDate), DATEPART(Month, SOH.OrderDate), 22. DATENAME(Month, SOH.OrderDate), PC.Name The shared dataset appears in Solution Explorer. 23. In the Report Data pane, create a dataset named EmpSalesMonth2008R2. 24. In the Dataset Properties dialog box, select Use a shared dataset, and click the dataset that you just created in Solution Explorer.
Create SalesEmployees2008R2 To create the dataset for an available values list for employees
1. In Solution Explorer, add a shared dataset named SalesEmployees2008R2. This data provides valid values for the @EmployeeID parameter. 2. Use the AdventureWorks2008R2 shared data source and the following query: 3. SELECT s.[BusinessEntityID], p.[FirstName] + N' ' + p.LastName AS Employee, e.[JobTitle] 4. FROM [Sales].[SalesPerson] s 5. INNER JOIN [HumanResources].[Employee] e ON e.[BusinessEntityID] = s.[BusinessEntityID]
6.
INNER JOIN [Person].[Person] p ON p.[BusinessEntityID] = s.[BusinessEntityID] The shared dataset appears in Solution Explorer.
7. 8.
In the Report Data pane, create a dataset named SalesEmployees2008R2. In the Dataset Properties dialog box, select Use a shared dataset, and click the dataset that you just created in Solution Explorer.
Change the Order of Parameters To change the order of parameters on the report viewer toolbar
1. 2. 3. 4. In the Report Data pane, click ShowAll. On the Report Data pane toolbar, click Move Down until the parameter is last in the list. Click ReportMonth. Click Move Up until the parameter is first in the list.
Configure ReportMonth
Configure @ReportMonth to accept values only from a set of values that you specify individually. The default value must be one of these values or the report will not automatically run.
6.
This sets the default value to July. When each report parameter has a default value, the report runs automatically on first view.
2. 3. 4.
On the General page, change Data type to Integer. On the Default Values page, select Specify values. Add a value. In Values, type 2007.
To add a rectangle
1. 2. Add a Rectangle at the bottom of the report, above the page footer. In Rectangle properties, do the following: a. On the General page, select Add a page break before.
b. On the Visibility page, select Show or hide based on an expression, and type: =NOT Parameters!ShowAll.Value In the following steps, add each text box to the rectangle as you complete it. Expand the rectangle as needed. By using the rectangle as a container, you can easily move all the text boxes as one unit.
2.
To add a text box that displays data source and dataset information
1. 2. To the report body, add a text box named DataSourceandDatasets with the following text: a. Data Source AdventureWorks2008R2: b. Create a Placeholder named AdventureWorks2008R2 with the following value: =DataSources!AdventureWorks2008R2.DataSourceReference c. Dataset EmployeeSalesYearOverYear2008R2: d. Create a Placeholder named EmployeeSalesYearOverYear2008R2 with the following value: =DataSets!EmployeeSalesYearOverYear2008R2.CommandText. e. Dataset EmployeeSalesDetail2008R2: f. Create a Placeholder named EmployeeSalesDetail2008R2 with the following value: =DataSets! EmployeeSalesDetail2008R2.CommandText. g. Dataset EmpSalesMonth2008R2. h. Create a Placeholder named EmpSalesMonth2008R2 with the following value: =DataSets! EmpSalesMonth2008R2.CommandText. Format the text as needed. For example, underline the dataset name. Drag the text box to the rectangle and adjust sizes as needed.
3. 4.
4. 5. 6.
Note
Because the report depends on shared datasets, the first time you deploy the report, you must deploy t
2. In a browser, navigate to the report server or SharePoint site, and verify that the shared data sources, shared datasets, and reports appear in the correct folders, and that you can view the reports.