I've created a report in SSRS with two report parameters. I'd like the second to update it's values based on the selection in the first. The first is a list of sales agents, and the second is a list of distributors. Each agent can have many distributors.
So if the report user selects an agent, I'd like only their distributors to show in list for the second parameters. Obviously the parameter values will come from a query, but I don't know how to make it rebind the list once they select an agent.
To set available values for the second parameter In the Report Data pane, in the Parameters folder, right-click the first parameter, and then click Parameter Properties. In Name, verify that the name of the parameter is correct. Click Available Values. Click Get values from a query.
In SQL Server Reporting Services or SSRS, Cascading parameters means one parameter value will be filtered depending upon other parameters. In this article, we will show you how to configure SSRS Cascading parameters example.
You can design the parent report to pass parameters to the subreport. A subreport can be repeated within data regions, using a parameter to filter data in each instance of the subreport. If you use a subreport in a tablix data region, the subreport and its parameters will be processed for every row.
A query parameter is passed to the data query engine to be incorporated into the SQL script's WHERE clause or some other part of the SQL that can accept parameters. A report parameter is passed to the report processor to be processed while the report is rendered on the client.
This works automagically if you order your parameters and datasets correctly
WHERE
clause in the datasets to make the dependencies correct across parameter variablesThis will work if your WHERE
clause in the second and subsequent datasets have variables that SSRS knows are populated from earlier parameters.
As an example, I have three datasets from the venerable pubs
database (sample in 2000).
pubslist
is used to populate the @p parameter, and looks like this:
select pub_id, pub_name from publishers
titleslist
populates the @t parameter, and looks like this:
select title_id, title from titles where pub_id = @p
Finally, reportdataset
looks like this:
select title, price, ytd_sales from titles where title_id = @t
The order of the parameters in the Report | Report Parameters
menu is crucial; because the datasets must be executed in the order shown above, and the @t parameter is in a dataset that relies on the @p parameter being set first, we move @p to the top of the list.
Now, SSRS evaluates the dataset needed to fill the dropdown for the first parameter with labels. It relies on a dataset that doesn't need a parameter, so can be produced immediately.
Then, having got that parameter value, it can populate the second parameter's dropdown. That in turn results in the report being produced.
You first create a dataset with a list of items which the user will select from.
Select ID,Agentname from Agents Order by Agentname
You then create the second dataset;
eg. Select ID,ItemName from Orders where agentid=@agentid
IN your report paramenter, you click on agentid parameter and then from a Query on available values. You select dataset1 and ID as value and AgentName as Label.
Your last dataset will be the actual data. In this You create your statement like :
Select Quantity, Amount From Orderdetails where OrderID=@orderid
In reporting service, you go to parameter and the set Order to get value from Dataset2
So the Order of parameter should be agentid, orderid. Reporting Service will automatically prompt for parameter by order.
You will most likely need to create a shared data source for the multiple datasets
if you preview the report, it will ask for a value entered for param_name before viewing the report...
now go to data tab, and add new dataset.... call it dsPopParam
Important note: in case the report did not render or exception was thrown, just switch to data tab again, select the report dataset and execute the query, you will be prompted to enter a value for param_name...enter it and execute it... then switch to preview tab and
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With