7
Lesson 5: Adding Parameters to Pass to a Drillthrough Report (SSRS) SQL Server 2008 R2 Other Versions 10 out of 13 rated this helpful - Rate this topic Drillthrough reports are a type of report that you access by clicking a link in the current report. When you click a text box that has a drillthrough action, you open the drillthrough report. If the drillthrough report has parameters, you must pass parameter values to each report parameter. In this lesson, you will design a new report to display detail data for a sales order that you specify with a parameter. You will open an existing report and create a drillthrough action for the sales order number. When you run this report and click on the sales order number, the new report opens and displays the details of that sales order. To add a new report to an open report server project 1. In Solution Explorer, right-click Reports, point to Add, and click New Item. 2. In the Add New Item dialog box, under Templates, click Report. 3. In Name, type Sales Order Detail.rdl, and then click Add.

Lesson 5 Adding Parameters to Pass to a Drillthrough Report

Embed Size (px)

Citation preview

Page 1: Lesson 5 Adding Parameters to Pass to a Drillthrough Report

Lesson 5: Adding Parameters to Pass to a Drillthrough Report (SSRS)SQL Server 2008 R2 Other Versions

10 out of 13 rated this helpful - Rate this topic

Drillthrough reports are a type of report that you access by clicking a link in the current report. When you click a text box that has a drillthrough action, you open the drillthrough report. If the drillthrough report has parameters, you must pass parameter values to each report parameter.

In this lesson, you will design a new report to display detail data for a sales order that you specify with a parameter. You will open an existing report and create a drillthrough action for the sales order number. When you run this report and click on the sales order number, the new report opens and displays the details of that sales order.

To add a new report to an open report server project

1. In Solution Explorer, right-click Reports, point to Add, and click New Item.

2. In the Add New Item dialog box, under Templates, click Report.

3. In Name, type Sales Order Detail.rdl, and then click Add.

Report Designer opens and displays the new report definition in Design view.

To create a reference to a shared data source

1. In the Report Data pane, click New, and then click Data Source.

NoteIf you do not see the Report Data pane, from the View menu, click Report Data.

2. In Name, type AdventureWorks_Ref. 3. Select Use shared data source reference.

Page 2: Lesson 5 Adding Parameters to Pass to a Drillthrough Report

4. From the drop-down list, select AdventureWorks.

5. Click OK.

To create a new dataset

1. In the Report Data pane, right-click the data source AdventureWorks_Ref, and then click Add Dataset.

2. In Name, type SalesDetails.3. Paste the following query into the Query

text box:

Copy

SELECT P.Name AS Product, SD.OrderQty AS Quantity, SD.LineTotal FROM Sales.SalesOrderDetail AS SD INNER JOIN Production.Product AS P ON SD.ProductID = P.ProductID INNER JOIN Sales.SalesOrderHeader AS SOH ON SD.SalesOrderID = SOH.SalesOrderIDWHERE (SOH.SalesOrderNumber = (@SalesOrder) )ORDER BY SD.SalesOrderDetailID

Notice that to create the field collection for the dataset, you do not need to run the query in the Query Designer with a query parameter value.

4. (Optional) Open the Query Designer and click Run (!) on the toolbar. Provide the following value for @SalesOrder: SO43659. The result pane shows 12 products. Click OK.

5. Click OK.6. In the Report Data pane, expand

Parameters, and verify that the parameter SalesOrder appears.

To add a table with dataset fields

Page 3: Lesson 5 Adding Parameters to Pass to a Drillthrough Report

1. From the Toolbox, drag a Table to the design surface.

2. From the Report Data pane, drag the following fields to table cells in the Data row: Product, Quantity, LineTotal.

3. Preview the report.

Before the report runs, you must enter a valid sales order number.

4. On the report viewer toolbar, in Sales Order, type SO43659, and then click View Report.

The report displays line totals for the specified sales order.

To format the table

1. Switch to Design view.2. Right-click the cell that contains

[LineTotal], and click Text Box Properties.

3. Click Number.4. In Category, click Currency.5. Click OK. 6. On the table, click the row handle for

the first row that contains the column headers. All the cells in the row are selected.

7. From the Format menu, point to Font, and click Bold.

When you view the report, the value for LineTotal displays as a currency and the column headers display in bold font.

Next, add the drillthrough action in the main report to specify this report.

To add a report drillthrough action to your report

1. In Solution Explorer, double-click Sales Orders.rdl. The report opens in Design view.

Page 4: Lesson 5 Adding Parameters to Pass to a Drillthrough Report

2. In the Order column, right-click in the text box that contains [Order], and then click Text Box Properties.

3. Click Action. 4. In Enable as a hyperlink, select Go to

report.

Another section appears in the dialog box.

5. In Select a report from the list, from the drop-down list, select Sales Order Detail.

6. In Use these parameters to run the report, click Add.

A new row is added to the grid.

7. In Name, from the drop-down list that shows the list of parameters defined for the report, select SalesOrder.

8. In Value, from the drop-down list, select [Order].

This binds the value from the main report to the parameter that the target report is expecting.

Next, change the text style and color for the drillthrough link.

9. Click Font.10. In Effects, from the drop-down list,

select Underline. 11. Next to Color, click (fx) to open the

Expression dialog box.12. Replace the default text Black with a

different color, for example, Blue.

NoteTo see valid values for font color, in the Values pane, click More colors. The Select Color dialog box opens. You can browse valid colors in this dialog box, and select the one that you want to use. Click OK.

13. Click OK twice.

Page 5: Lesson 5 Adding Parameters to Pass to a Drillthrough Report

The text box you added now has underlined text that is the color that you chose. These visual indicators help report readers understand that there is an active link to another report.

To preview the report

1. Click Preview. The Sales Orders report displays sales orders grouped by date. The Order column displays sales order numbers that are drillthrough links.

2. Click a sales order number with a drillthrough link.

The report specified by the drillthrough link runs and displays the order details for the sales order number that you clicked.

NoteTo return to the main report, use the back arrow on the report viewer toolbar.

Next Steps

You have successfully completed the Adding Parameters to a Report tutorial. To learn more reporting techniques, see Tutorials (SSRS).