In This Topic
When a parameter’s value list depends on the value of another parameter, the report collects the required parameter value and uses it to create the value list for the second parameter. This cascade of parameter values is sometimes also called dependent or hierarchical parameters.
You can create cascading parameters in a Page or an RDLX report using the following steps.
Note: This topic uses the Reels database. The Reels.db file can be downloaded from
GitHub.
- In the Report Explorer, right-click the Data Source (DataSource1 by default) node and select Add Data Set to create a dataset named Regions.
- On the Query page of the DataSet Dialog, use the following SQL Query to fetch data from the Regions table.
SELECT RegionID, Region FROM Regions
- Click OK to close the dialog.
- Follow the step 1 to create another dataset named Districts and on the Parameters page of the DataSet Dialog, click the Add(+) icon to add a parameter named Region with the value set to:
=Parameters!Region.Value
This parameter is added to the Report Parameters collection later.
- In the Districts dataset dialog, on the Query page, add the following SQL query to fetch data from the Districts table. This query depends on the Region parameter.
SELECT DistrictID, District FROM Districts WHERE Region = ?
- Click OK to close the Districts DataSet dialog.
- Follow the step 1 and create another dataset named StoreNames and on the Parameters page of the DataSet Dialog, click the Add(+) icon to add a parameter named DistrictID with the value set to:
=Parameters!DistrictID.Value
This parameter is added to the Report Parameters collection later.
- In the StoreNames dataset, on the Query page, add the following SQL query to retrieve data for the selected region from the selected district. This query depends on the DistrictID parameter.
SELECT StoreID, StoreName, OpenDate FROM Store WHERE NOT StoreID = 0 AND DistrictID = ?
- Click OK to close the StoreNames DataSet dialog.
- In the Report Explorer, right-click the Parameters node and select Add Parameter
- In the Report - Parameters dialog that appears, add a parameter named Region with an Integer data type. On the Available Values tab, select From query and set the Dataset to Regions, the Value field to RegionID, and the Label field to Region.
- Click OK to close the Report - Parameters dialog.
- Follow the same process as steps 10 and 11 to add a second parameter named DistrictID with an Integer data type. On the Available Values tab, select From query and set the Dataset to Districts, DistrictID for the Value field, and District for the Label field.
- Drag and drop a Table data region (or any other data region) onto the design surface, and drag the StoreID, StoreName and OpenDate fields onto the Details row.
- Preview the report to view the result.
Notice that the two drop down lists, for regions and districts appear in the Parameters sidebar while the second drop down list remains disabled until a region is selected. Click the View Report button to see the StoreID, StoreName and OpenDate values returned for the selected region and district.
Note: In a Page report, when you have multiple datasets in the report, you need to set the DataSet property on the General tab of the FixedPage dialog in order to specify which dataset is used to display data in the report.