How to pass variables as parameters to subreports using SSRS - reporting-services

I am working on an SSRS project which has main report and sub reports. To the subreport, I would like to pass a variable that uses stuff sql syntax. This variable will have comma separated values. I would like to know how to pass variables as parameters to subreports.

If you go to the Action tab in the properties window, there is an area at the bottom which you can assign the parameters to be passed to the next report. If you want to pass an existing parameter, you would send
=Parameters!MyParameterName.Value
as the value.
I'm not sure what "stuff sql syntax" means, but you can pretty much put whatever you want into the value field as a string and parse it in the next report.

Related

Issues with Passing Multi-value Parameters to a Drill through Report

I have two reports were I pass multi-valued parameters to it's underlining data and both reports work very well independently. The parameter strings are being split using the function dbo.UTILfn_Split. When trying to drill from the main or Summary report into the sub or Detailed report all other parameters field in the report are populated except the multivalued parameter field. The parameter lists or value are listed in the detailed report but not selected and therefore cannot run the report even though the detailed report parameter property is set to allow multiple values. In both reports, the where clause is set "IN" not "=." How do I fix this?
In your Summary Report, when you pass the parameter to the sub or detailled report, the passed value parameter should be like this expression:
=join(parameters!yourMultivaluedParameter.Value,",")
after that, you pass the name of the parameter to the corresponding parameter in the dataset Detailled report.
In your SQL (SP), get the multivalues of the parameter by spliting it with your function
like following, depending of the result of your function, for exemple:
INNER JOIN dbo.SplitFunction( #yourMultivaluedParameter,',') tmp on tmp.yourColumn = ...etc...
Hope it helps...

3rd party application passing url parameters to SSRS report

The 3rd party application is passing the parameter values as follows: Parameters=Collapsed&Priority=P1%7cP2. It is using a %7c (which is a pipe) instead of passing the parameters the way SSRS is looking for them as follows: Parameters=Collapsed&Priority=P1&Priority=P2. The parameter is multi select in SSRS and works in Report Builder just fine. My where clause is using IN (#priority).
How can I get SSRS to use the parameter values that are being passed in the URL?
If you can't change the application to provide the correct multi-value parameter syntax (...&Priority=Value1&Priority=Value2&Priority=Value3...) you can set the value that is passed to your dataset in the Parameters section of the dataset properties to be the following expression:
=split(Parameters!Priority.Value,"|")
This will take the pipe delimited list and separate it into a list of items that can be passed to your SQL query and used with the IN function.
I have created a dummy report to demonstrate this:
Parameter
Dataset
Dataset Properties
Report Result

How do I get an RDLC report to run report custom code?

I have an RDLC report in VS 2013 that has two distinct sections. I'd like to show a footer only in the first section. To do this, I have a report variable called IsFirstSection that is set to "True". In my footer I have an if statement that displays text if this variable = "True".
Before the second section is displayed on the report I would like to set this variable to false. To do this, I have a function in the report custom code called SetVariableValue that takes a variable and a value and does just that. I have a text box before the second section that calls this function with Code.SetVariableValue(Variables!IsFirstSection, "False"). However, this code doesn't seem to be executing as IsFirstSection is still "True".
When I do this exact set up in an RDL report it works correctly. I even tried making a custom code function in the RDLC that just returns a string and when I call it from a text box expression nothing is displayed. How can I get the RDLC to run report custom code?
A Report Variable seems a poor choice for this requirement. It's probably just chance that it appears to work under some conditions. Some quotes from the doco:
"By default, a report variable is calculated once ..."
"You cannot control when the report processor initializes a variable or evaluates an expression that updates a variable."
https://msdn.microsoft.com/en-us/dd255208.aspx
I would use a ReportItems reference instead. This would likely point at a textbox which presents field that changes value between "sections".

How to populate a report level variable from a dataset

I want to populate a report level variable from a dataset.
Background: I have a report that needs to perform a DB lookup to get a single row/column value. That value needs to populate a report level variable. Of data type datetime.
Here is something I have tried.
Click in report area
Under report properties I navigate to variables
Create a new variable and assign it a name.
Click on the "fx" button to open the dialog.
I use the "First" function in an attempt to assign the value.
I get the "...value expression for the report 'body' uses aggregate function First..." error.
Is there any way to make this happen at the report variable level?
Thanks,
Donnie
Why not use a parameter? You can set the default value based on a query. If you don't want your users to overwrite it, make it hidden.

Passing values for multi-value parameter in SSRS query string

I have two reports built using SSRS 2005. The first report is set to navigate to the second when a specific field is clicked.
There is a multi-value parameter on the second report. I need to pass multiple values for this parameter in the "Jump to Report" string when calling this report. Is there a way to pass multiple values? I have tried Field.Value but that doesn't work for multivalue, it wants Field.Value(0). Or can you pass a parameter that will cause the Select All value to be selected?
I figured it out. Looks like one of the parameters being passed in was Field.Value(0) instead of Field.Value. That was messing things up.