简体   繁体   中英

SSRS multiple column values into 1 parameter

I am trying to develop an SSRS report that contains 1 parameter that is linked to multiple column values. Suppose I am creating a report for a company that has various departments and these departments fall under 2 organizations within the company:

EmployeeID |Name  | Dept_number
-------------------------------
1          |Tom   | AB12
2          |Bob   | AB10
3          |John  | AB08
4          |Kim   | AB09
5          |Jack  | AB05

I am able to create a parameter for each department number, but what I want to do is aggregate the department numbers into one parameter with 2 options: Organization A & Organization B. Is there a way to do this in SSRS when I am connecting directly to the database?

Supposing these table structures:

CREATE TABLE Depts (DepartmentId INT, Dept_number VARCHAR(4), OrganizationId INT)
CREATE TABLE Orgs (OrganizationId INT, Org_name VARCHAR(50))

You can fill parameter values like this:

SELECT Dept_number, Org_name + ': ' + Dept_number AS OptionText
FROM   Depts
       JOIN Orgs ON Orgs.OrganizationId = Depts.OrganizationId

And then query your SSRS dataset with a where clause:

SELECT *
FROM   Employee
WHERE  Employee.Dept_number = @MySsrsParameter

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM