Düzenle

Aracılığıyla paylaş


Add a subreport and parameters to a Report Builder paginated report

Applies to:  Microsoft Report Builder (SSRS)  Power BI Report Builder  Report Designer in SQL Server Data Tools

Add subreports to a paginated report when you want to create a main report that's a container for multiple related reports. A subreport is a reference to another report. To relate the reports through data values, you must design a parameterized report as the subreport. For example, to have multiple reports show data for the same customer you could create a report that shows the details for a specific customer. When you add a subreport to the main report, you can specify parameters to pass to the subreport.

You can also add subreports to dynamic rows or columns in a table or matrix. When the main report is processed, the subreport is processed for each row. In this case, consider whether you can achieve the desired effect by using data regions or nested data regions.

Note

You can create and modify paginated report definition (.rdl) files in Microsoft Report Builder, Power BI Report Builder, and in Report Designer in SQL Server Data Tools.

Prerequisites

Add a subreport

  1. On the Insert tab, select Subreport.

  2. On the Design surface, choose a location on the report and then drag a box to the desired size of the subreport. Alternatively, select the Design surface to create a subreport of default size.

  3. Right-click the subreport, and then select Subreport Properties.

  4. In the Subreport Properties dialog box, enter a name in the Name text box or accept the default. The name must be unique within the report. By default, a general name such as Subreport1 or Subreport2 is assigned.

    Screenshot of the Subreport Properties dialog box highlighting the Name field on the General tab.

  5. In the Use this report as a subreport box, select Browse, or enter the name of the report. Selecting Browse is preferred because the path to the subreport is specified automatically. You can specify the report in several ways. For more information, see Specify paths to external items in a paginated report (Report Builder).

  6. (Optional) Choose Yes for Omit border on page break to prevent a border from being rendered in the middle of the subreport if the subreport spans more than one page.

  7. Select OK.

Specify parameters you want to pass to a subreport

  1. In Design view, right-click the subreport and then select Subreport Properties.

  2. In the Subreport Properties dialog, select the Parameters tab.

  3. Select Add. A new row is added to the parameter grid.

  4. In the Name text box, type the name of a parameter in the subreport or choose it from the list box. This name must match a report parameter, not a query parameter, in the subreport.

  5. In the Value list box, type or select a value to pass to the subreport. This value can be static text or an expression that references a field or other object in the main report.

    Screenshot of the Subreport Properties dialog box showing one example parameter on the Parameters tab.

    Note

    In Report Builder, if a parameter is missing from the Parameters list and the subreport has a default value defined, the subreport is processed correctly.

    In Report Designer, all parameters that are required by the subreport must be included in the Parameters list. If a required parameter is missing, the subreport isn't displayed correctly in the main report.

  6. Repeat steps 3-5 to specify a name and value for each subreport parameter.

  7. To delete a subreport parameter, select the parameter in the parameter grid, and then choose Delete.

  8. To change the order of a subreport parameter, select the parameter, and then choose the up or down button.

    Changing the order of a subreport parameter doesn't affect the processing of the subreport.