Searchable / Dependant Parameters in SSRS

Posted on July 29, 2008. Filed under: SSRS | Tags: , , |

Introduction

The idea behind this post came from a question from a colleague, they wanted an SSRS report where they could select from a list of employees but the list could be filtered by searching on the surname (i.e. you enter ‘S’ and it would load a dropdown of all employees whose surname start with S).

It’s quiet an interesting requirement because we have very little control over the manner in which parameters are selected by the user. There is however a very simple way to achieve this utilising dependant parameters, in SSRS we can set the default value or available values to be dependant on the value selected in a previous parameter.

Getting Data On The Report

Lets start from the data for the report and work backwards, I’m using the Adventure Works sample database and we are going to load pay rate records for an employee.

We can create a new dataset that selects all pay records for an employee;

I’ll add a simple table to the report to display the returned records;

And when we run the report we are prompted to enter an employee ID;

Adding a Searchable Drop Down for Employee

SSRS will allow us to use a query to retrieve possible values for a parameters, so lets add a dataset that will load a list of employees whose surname starts with a specified search phrase;
Note the @Search parameter that is highlighted

Now if we select Report -> Report Parameters from the menu we will see Visual Studio has automatically generated an EmployeeID and Search parameter for us. First we need to move the Search parameter to be the first in the list since the values of the EmployeeID are dependant on it. Next highlight the EmployeeID parameter and in the “Available Values” sections tick the “From Query” radio button, select CandidateEmployees as the dataset, EmployeeID as the value field and DisplayName as the Label Field.

When we run the report the Employee dropdown is greyed out, if we enter “R” into the search box and then press tab the employee dropdown will be populated with all employees whose surname starts with R, we can select one and then click “View Report”… Hey Presto!!!

Advertisement

Make a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

Gravatar
WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

2 Responses to “Searchable / Dependant Parameters in SSRS”

RSS Feed for RoMiller.com Comments RSS Feed

I like this approach, but wondered whether it could be adapted to cope with multi-select list boxes,i.e. ‘remember’ selections between searches. e.g. I search for staff whose surname begins with ‘S’, select the person I want; then do a second search for a staff member whose name begins with ‘B’


Where's The Comment Form?

    About

    Rowan works as a Program Manager for the ADO.NET Entity Framework team at Microsoft. He speaks at technical conferences and blogs at http://romiller.com. Rowan lives in Seattle, Washington with his wife Athalie. Prior to moving to the US he resided in the small state of Tasmania in Australia. Outside of technology Rowan's passions include snowboarding, mountain biking, horse riding, rock climbing and pretty much anything else that involves being active. The primary focus of his life, however, is to follow Jesus.

    RSS

    Subscribe Via RSS

    • Subscribe with Bloglines
    • Add your feed to Newsburst from CNET News.com
    • Subscribe in Google Reader
    • Add to My Yahoo!
    • Subscribe in NewsGator Online
    • The latest comments to all posts in RSS

    Meta

Liked it here?
Why not try sites on the blogroll...

Follow

Get every new post delivered to your Inbox.