Dynamic subreport in SSRS 2008 - reporting-services

I would like to set up a dashboard report in SSRS that contains a bunch of sub reports, but have the reports that are displayed be configurable at run time.
I.E. there could be 4 parameters which represent the names of 4 reports. The report contains 4 reports, and the name of each sub report should be taken from one of the parameters.
It looks like I can't do this, as the 'Use this report as a subreport' property is a dropdown and doesn't provide a way of configuring it as an expression.
Am I right?
Thanks,
Rich

I figure your scenario is just to display one at a time. I needed to do almost the same thing. I have a main report in which I wanted a dynamic number of different subs to be displayed. I solved it like this:
A main report (Main) with a tablix containing a subreport (SubMain), the dataset for Main passes id, subid and subtype. SubMain has no dataset.
And directly in the SubMain I added all my subs (SubDetail) which have their own dataset.
And then I set visibilty for SubDetails depending on type.
/Erik

Normally you'd have to define each subreport in the main report and then set visibility. Or use drill through to emulate navigation.

Related

SSRS Subreport disappears after page is changed

I'm using Visual Studio 2019 with SSDT(SQL Server Data Tools) and "Microsoft Reporting Services Projects" to create a SSRS Report. In this Report I have several Subreports to show detail information.
It can happen that one of the subreports shows no additional data. In this case I still want the structure of the Subreport to be shown, like this (table structure with thinner Bordes is the Subreport):
But when I switch to another page and back to this page of the Report, the structure is gone:
This seems to be the case, when there is no information in the Subreport.
There are no visibility properties set, neither in the Subreport nor in the "parent"-Report, so everything should be visible all the time.
Yes it will happen because your sub report does not return anything and hence the blank.
For Testing just try running one of your sub report only (without main report) with parameter which does not return data and you will see your sub report page is completely empty
Now how to solve this issue:
For your sub report:
I would add static table (without datasets) and add it on top of your tablix.
I will add visibility rule to this static table to show only when your datasets does not return data. so that this static is visible only when original subreport data is not available, else you have your subreport data been shown.
This happend because SSRS think should hide the subreport since all the dataset are empty (or the only one you have) so to avoid that in your subreport just add a new dataset with
'select 1 as one'
that will do the job

Passing multi-value string consisting of TFS area paths to subreport in SSRS

I'm having a problem with passing mulit-value argument to subreport. We have a report that is generating data from Team Foundation Server about velocity, burndown, bugs etc. The main report is pointing to a few subreports (for each team) were this measures are being done. On that 'Team' subreports we have next subreport for generating data for Bugs and with this I have problem (I'm getting subreport errors).
To calculate values that we want, we're passing an TFS AreaPath for this Bug subreport from main report level (it's a simple string eg. [Work Item].[Area Hierarchy].[Area2].&[-8426352345429395890]&[-7702890005762484781]) and it's working ok. Now on, we want to pass multi values so that Bug subreport will count Bugs for two or more Area Paths. Bug subreport is ready for that as when I generate it standalone I can choose more than one Area and it's counting and showing data properly. The only thing I have now is a problem how to pass multi-value string to this sub report so that it work properly.
We have something like this:
Main Report -> 'Team' Subreport -> Bugs Subreport
On Main Report:
Parameter 'BugAreaParam' with string [Work Item].[Area Hierarchy].[Area2].&[-8426352345429395890]&[-7702890005762484781] as value passed to 'Team' Subreport.
On 'Team' Subreport:
Parameter 'WorkItemAreaPath' passed to 'Bugs' subreport with value from BugAreaParam set as an expression: =Parameters!BugAreaParam.Value
On Bugs Subreport:
Parameter 'WorkItemAreaPath' that is taking value and generates data. It is a multi-value and when I generate it as standalone report I can pick multi-value to generate data.
The question is, how to properly set parameter 'BugAreaParam' on Main report so that it pass two or more values eg. [Work Item].[Area Hierarchy].[Area2].&[-8426352345429395890]&[-7702890005762484781] and [Work Item].[Area Hierarchy].[Area2].&[-55555]&[-44444] and Bugs subreport will generate Bugs from this two Areas?
Thanks you very much for any help!
BR,
Damian
You could try Edwin's solution in this case:
Make sure that the parameter in the subreport is set to allow
multiple values.
Make sure you are passing the parameter from the main report to the
subreport as [#paramName] and not "=Parameters!ParamName.Value(0)"
as this indicates to retrieve only the first value.
Set the subreport parameter to visible and ensure manually
selecting/inputting multiple values returns appropriate results.
If all else fails, try using a formula like this
=Split(join(Parameters!ParamName.Value,","),",") which creates a comma separated list of the parameter values and then splits it out
into an array.

How to group my subreports into 1 header & 2 details output

Currently I've created below report with total of 3 subreports, the expectation was using DN_Header as main header sub report for PickSlip header & PickSlip details.
But it seems the output I'm having now is totally a mess whereby "DN_HEader" only show 1 of the data & applied toward all sub reports which is not right.
So how can i make it into such output? I'm not familiar with the grouping if there's any good reference that will be great. Thanks
You will need to create a few sub reports. You may have most of them completed already but I'll go thru them.
Here's a rough sketch of the layout based on your expected output image.
NOTE: Subreports A and B could be combined into a single report. It depends if you plan to use any parts elsewhere. Combining then might make this a little easier.
Subreport A. This is just you details section. It should accept parameters to filter data as applicable.
Subreport B. This will be your details header plus your details body. Again it must accept parameters to filter data as applicable.
SubReport C. This will contain a header and a single cell tablix. This will contains a dataset that returns 1 record for every instance of subreport B that needs to be shown. It will contain a tablix with a single cell. The tablix's dataset will point to the new dataset. In the cell, insert a subreport and set it to point to SubReportB. Finally pass in parameters from the dataset tho the subreport (in the subreport properties) so SubReportB shows the correct data.
Main report. This will be very similar to subreportC, it will contains a single cell tablix containing SubReport C in it's cell and dataset that will be used to loop thru each required instance of SubReport C
Hope that makes sense?

SSRS Pull Variables Or Values From Sub Report Into Main Report

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.
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
All parameters that are required by the subreport must be included in
the Parameters list. If a required parameter is missing, the subreport
is not displayed correctly in the main report.
For citing authoritative sources:
This discussion sums it up:
No, referring to a report item in a subreport is not allowed.
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:
You are going to need to replace the subreport item with a data region
like list, table, or matrix to be able to get the proper reference you
are looking for.
[Skipping down to another post]...
Now, it seems you want to calculate the
difference between main report and the subreport. Also, because they
have the different data source, so you cannot use nest
table/matrix/list, right? If so, one workaround I can think of is
pass parameter to the sub report and calculate the total/subtotal in
sub report. I mean, create several hidden/ internal parameters, pass
the values from main report to sub report through parameters and then
calculate the total/subtotal there.
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.
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
WhilePrintingRecords;
shared Numbervar myTotal := 0;
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
WhilePrintingRecords;
shared Numbervar myTotal := 0
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
WhilePrintingRecords;
shared Numbervar myTotal;
myTotal := myTotal + 200; //or any formula or field
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
WhilePrintingRecords;
shared Numbervar myTotal;
myTotal
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

How to reference in SSRS report (in client mode) objects from application

I have a report created in SSRS in client mode, which is run disconnected: I create the data source in code and pass to the report as a DataView. It works ok.
But I need to be able to reference from the project to some objects (variables, whatever) from my application, as follows:
I need some totals that are not calculated based on data in report. e.g. the reports show total sales in a period, with own total, but I need to display a field in report footer - previous month total (actually they are about 10 other "previous" totals).
I need to have some columns show / hide based on some settings in the application (e.g. I have application option : Show Previous month sales)
Any thoughts on how to do this?
Thank you
Q1-> In order to use data in your reports, you need to specify the data inside of a Datasource object. You cannot simply use the variables if that is what your intentions were. So yes, you are doing this the right way. *** Sorry, you could theoretically used Report Parameters for this.
Q2-> This is the real reason to use Report Parameters. You can pass parameters to the report to do exactly this. If the HideColumn parameter (for example) is set to true, you could hide all the columns that need to be hidden.
http://msdn.microsoft.com/en-us/library/ms251750%28VS.80%29.aspx
For question 1 - the data - the easiest approach would be to create a DataTable in memory and add it as another dataset OR to add fields for your original dataview that contain these values.
Question 2 - To hide or show the columns based on settings make the column visibility an expression based on the value of a parameter, in your code behind set the parameter value to your application setting.