SSRS Subreports are extremely helpful, when we need to embed multiple reports in a single report.
The main report serves as a container for multiple sub-reports.
SSRS gives us complete control over what parameters to be passed to the sub report.
Many times this is useful in matrix reports too.
Lets look at an example of a sub-report.
We are going to create a main report with 1 parameter.
As soon as someone selects a parameter, relevant data is displayed + the sub report is also filtered and displayed in the main report itself.
Step 1: Create a main report (Steps to create a basic report can be found in the previous tutorials)
I have the following dataset:
SELECT [TerritoryID]
,[Name]
,[CountryRegionCode]
,[Group]
,[SalesYTD]
,[SalesLastYear]
,[CostYTD]
,[CostLastYear]
,[rowguid]
,[ModifiedDate]
FROM [AdventureWorks].[Sales].[SalesTerritory]
Where CountryRegionCode = @CRC
Step 2: Create a parameter called CRC.
Step 3: Your Main report would look something like this.
Step 4: Now lets add a sub-report and pass in the same parameter to it.
Drag and drop a sub-report control from the toolbox.
Step 5: Now click on the sub-report properties.
Step 6: Lets us the previous tablix report that we created as our sub-report.
Step 7:
Choose the parameters tab, and configure the parameters
Step 8: click OK and hit preview.
You should be able to see the main and the sub-report.
The main report serves as a container for multiple sub-reports.
SSRS gives us complete control over what parameters to be passed to the sub report.
Many times this is useful in matrix reports too.
Lets look at an example of a sub-report.
We are going to create a main report with 1 parameter.
As soon as someone selects a parameter, relevant data is displayed + the sub report is also filtered and displayed in the main report itself.
Step 1: Create a main report (Steps to create a basic report can be found in the previous tutorials)
I have the following dataset:
SELECT [TerritoryID]
,[Name]
,[CountryRegionCode]
,[Group]
,[SalesYTD]
,[SalesLastYear]
,[CostYTD]
,[CostLastYear]
,[rowguid]
,[ModifiedDate]
FROM [AdventureWorks].[Sales].[SalesTerritory]
Where CountryRegionCode = @CRC
Step 2: Create a parameter called CRC.
Step 3: Your Main report would look something like this.
Step 4: Now lets add a sub-report and pass in the same parameter to it.
Drag and drop a sub-report control from the toolbox.
Step 5: Now click on the sub-report properties.
Step 6: Lets us the previous tablix report that we created as our sub-report.
Step 7:
Choose the parameters tab, and configure the parameters
Step 8: click OK and hit preview.
You should be able to see the main and the sub-report.
No comments:
Post a Comment