Tablix中的SSRS分组

时间:2018-11-26 23:16:11

标签: reporting-services dropdown ssrs-grouping

在使用相同数据集生成Tablix时需要帮助,但应根据下拉输入选择(多个值)单独显示。目前,我正在开发Tablix,请告诉我是否可以使用其他方法来实现输出。

这是我的示例,其中有多个输入选择的下拉菜单,当我选择两个学生时,我将结果放入一个表中,而我想根据studentID分成两个表。

1        Past Due
2     Yet to Calc
3         Overdue
4         Overdue
5         Overdue
6     Yet to Calc
7        Past Due
8        Past Due
9        Past Due
10    Yet to Calc
11        Overdue
12    Yet to Calc
13       Past Due
14       Past Due
15       Past Due
16    Yet to Calc
17        Overdue
18        Overdue
19        Overdue
20        Overdue
21    Yet to Calc
Name: Status, dtype: object

电流输出

CREATE TABLE #tmpStudent( ID INT IDENTITY(1,1), Name varchar(150))

INSERT INTO #tmpStudent(Name)
VALUES('John') ,
('Mike'), 
('Albert')

CREATE TABLE #tmpDepartment (ID INT
IDENTITY(1,1), StudentID INT, DepartmentName VARCHAR(100))
INSERT INTO #tmpDepartment ( StudentID, DepartmentName)
VALUES(1, 'Computers'), 
(2, 'Computers'), 
(1, 'Science'), 
(3, 'Mechanical')

DECLARE @xStudent VARCHAR(30) ='John,Mike'

DECLARE @Sql NVARCHAR(MAX)

SET @Sql = 'SELECT s.ID, s.Name, d.DepartmentName
            FROM #tmpStudent s 
            INNER JOIN #tmpDepartment d 
             ON s.ID = d.StudentID
            WHERE s.Name IN('''+ Replace(@xStudent, ',', ''',''') + ''')
            ORDER BY s.ID'
--PRINT @Sql 
exec sp_executesql @Sql

DROP TABLE #tmpStudent, #tmpDepartment

以下是例外的输出,其中我必须基于StudentID(基于下拉列表中的多个输入选择)重复相同的tablix

ID  Name    DepartmentName
1   John    Computers
1   John    Science
2   Mike    Computers

0 个答案:

没有答案