I have a main report with several sub reports, each of these with slightly different queries and different ways to show the data.
So, in my situation, I have a textbox that needs to compile data from a few different reports with varying criteria. E.G.
MainReportTextbox =(Sum(columnA, "Main Dataset"))-(SubReportTextBox))
OR
MainReportTextbox =(Sum(columnA, "Main Dataset"))-(subReportVariable))
I saw a few suggested solutions, such as this. Which uses the =[Reports]!MainReport!SubReport!Textbox
scheme. The problem is that [Reports]
is not a recognized identifier.
I did consider to scrap sub reports and just have everything run on the same main report, but we lose the functionality of being able to use the reports individually, without maintaining the same thing in two places.
So I guess my question is, can you pull variables or element(particularly textboxes in a table) values from sub reports?
If the answer is simply no, please show me some information about why it is no or how it is no from MSDN or a valid source and give some valid counter suggestions.
Create variable in main report and update it in sub report so you can get value back to main report
ex: Create formula in main report with name {@Total} place flowing in it
NOTE : placing ; will not print value and without ; will print value in above example value will not be printed if you want to print value of formula just remove ; from second line ex
now place {@Total} in report header of your main report now create second formula in sub report where you want to add subtotal to main report formula with name {@addTotal} place following lines in it
add this formula to place in sub report where you want to add value to total
now create formula in main report to show grand total with name {@showTotal} and place following lines in it
place {@showTotal} in your main report where you want to show this value in report but remember one thing you should place this formula after sub-report.
NOTE : to assign value to variable use := operator
The links in the question and comments sometimes refer to non-SSRS reports: the syntax
[subreport].[Report]![MyFieldName]
or[Reports]![YourReportName]![YourSubReportName]![TheValueFromTheSubReportYouWantToReference]
are not used in SSRS. It is, however, used in designing MS Access reports, as ojeffrey points out in the discussion you link to.There is no common method to access data in a subreport. The SSRS model is that parent report data is processed, subreport data is processed, the subreports are rendered, results go back to the parent, then parent is rendered, including the subreport as appropriate. The only data passed between the two is parameters are passed into the the subreport, and rendered output is passed back to the parent. You'll see the that data passed in from the parent must be as report parameters here: http://technet.microsoft.com/en-us/library/ms160348(v=sql.100).aspx
For citing authoritative sources: This discussion sums it up:
But that is a bit old, there is also this more recent discussion of work-arounds, provided by Microsoft employee and a MS BI MVP:
Jeroen's answer to the linked question point towards the direction I would go: use a "Shared Dataset" and enable caching if the dataset is slow to execute. The same dataset execution can then be used for the parent and subreports. This can change the use of parameters: they usually get moved from the SQL query to the filter of the Dataset in the report.
But with the
Lookup
function introduced in SSRS 2008R2, you can get very flexible with report level joins between datasets.The details of how I'd design this depend a lot on how much other data needs to get passed back and forth, and how neatly the queries for the reports can be knit together.