Updated April 3, 2023
Introduction to SSRS Subreport
The following article provides an outline for SSRS Subreport. SSRS reports enable users to include one or more linked reports in the Data area. Its purpose is to display another report within the current one, providing extra report customization options. A subreport in the report included inside another report, for example, would be two reports, one Master and the other Child, with the Master invoking the Child report based on specified criteria. The master report’s parameters can be passed to the child report or subreport, which will complete its function.
What is SSRS Subreport?
Because the subreports are another report, anyone can configure them however we like; be cautious of any rendering or performance limitations. Let’s imagine we’ve created several reports, but we would like to use one of them in a new report (Main Report). Hence, in SSRS, one can use the Sub Report Item to call whatever report. Following the development and testing of an SSRS report on the server, the report is deployed to the running server, where the user can view it. Users can access SSRS reports from anywhere if deployed in a web environment.
Subreports have the following benefits:
- First, permit us to combine multiple linked reports into a single report.
- For example, we can nest or insert one report inside another using SSRS sub-reports.
- Allows us to send parameters (Parameter values) from the main report to the SSRS sub-report.
- If the SSRS sub-report is nested within a table or lattice, the sub-report will be re-created for each column. Otherwise, it will only appear once.
A subreport in a report is functionally analogous to a frame on a Web page. It’s being used to put a report inside another report. A subreport can be created from any document. The subreport report is normally kept in the same directory as the parent report on a report server. The parent report can be expected to transmit parameters to the subreport. A subreport can be reused within data areas, with every occurrence of the subreport employing a parameter to filter data.
How to Create an SSRS Subreport?
A subreport item can show numerous data sets in a data region or manage multiple reports in one report. As a result, we can quickly create many small reports and integrate them into a major report. Whether the report server is in local mode or SharePoint essential material affects the syntax used to specify the subreport. To review a subreport in the main report in Report Builder, either report must be on the same report server or specify the subreport’s entire path.
If the findings are to be delivered to a SharePoint Integrated SSRS server, the primary and subreports must be from the same folder, and the report’s name should include the file extension. The page splits specified inside the subreport would be ignored if contained within a table or matrix cell. A subreport could be placed in an empty place in the reporting body of the parent report, and it can be placed in a data zone. When we embed a subreport in a data area, this will repeat for every grouping or detailed row.
Subreports, for example, can be used to create side-by-side reports, master-details reports, presentation books, and so on.
Creating a report in SQL Server Data: This will then launch a VS 2012 and Opt a Report Server Project.
Adding a Data Source:
Select a New Data Source By right click on the folder Shared Data. And by then, select the Connection String.
Adding a DataSet:
Select the Query button to choose a new Dataset.
Next, in the Query Designer, add the respective details of a customer.
Imposing the Main Report:
Select a Report from the wizard and do the following steps:
Drag and drop the list item from the Toolbox onto the main report.
Similarly, do for other fields to add an item.
Now comes the main part of the subject to add SSRS Sub-report.
The next step is to add the parameters by choosing an Add Parameter Option.
The Properties window for the Sub-report appears. From the report server, navigate to and pick the report name (Report1) we wish to use as a sub-report. To check the sales analysis, click preview and input a CustomerID in the parameter box.
Example of SSRS Subreport
Two subreport components will be displayed in the report, and employee information will be displayed in the child report. Finally, I’ll link the child report to the main report’s subreport items.
We’ll have two reports to go over. The procedures would be the same for both reports; however, we will run the query below in the case of the master report.
Code:
SELECT
[PatientID],[PatientName],[BelongsTo]FROM [SSRSExperiment].[dbo].[tbl_Patients]
So for the subreport, we’ll run the query below.
Code:
SELECT
[PlayerName] ,[Matchdone] ,[RunsScore] ,[Wickets] ,[Fee]
FROM [SSRSExperiment].[dbo].[tbl_Players]
WHERE [BelongsTo]= @CountryName
It’s worth noting that we’re using the @CountryName argument. As a result, the subreport will be prepared at execution depending on the parameters supplied. As seen below, we will also have two documents in our project once the reports are completed.
As illustrated below, click the Test Connect button to see if the report’s connection is functional or not.
Next, while executing Sub-report alone, we yield the below snippet.
Imposing a subreport in the master report.
The next step is to choose a Subreport property and enter the necessary parameters.
Upon pressing the Add button on the Parameters tab, give the option the name “CountryName” and the value “=First(Fields!BelongsTo.Value, “DataSet1″).” When you’re finished, click the OK button.
Finally, a Sub-report has been generated like this:
The tutorial component of the Sub-report deployment into the main report is now finished.
Conclusion
The article describes the process for creating sub-reports in the report designer and builder. It also depicts the SSRS report deployment process. And also, we have touched upon their creation and advantages in brief.
Recommended Articles
We hope that this EDUCBA information on “SSRS Subreport” was beneficial to you. You can view EDUCBA’s recommended articles for more information.