我是Pivot& amp;的新手。 SSRS,我需要创建一个类似于数据透视表的报告。
报告布局如下:
Area_1 Area_2 Area_3 Area_4 ... Area_N
A_Percent
B_Percent
C_Percent
D_Percent
由于“Area_N”是动态的,因此我的表格布局如下:
Area A_Percent B_Percent C_Percent D_Percent
---- --------- --------- --------- ---------
Area_1 45 55 66 77
Area_2 22 33 11 55
Area_3 12 45 88 36
Area_4 67 23 37 28
...
Area_N 76 67 35 28
所以我的问题是:
欢迎所有大师评论。 非常感谢!
答案 0 :(得分:14)
首先 - 您可以在SSRS 2005(或更高版本的Tablix)中使用Matrix,它将为您提供所需的内容。但是,你遇到的问题是矩阵在垂直格式中的效果更好。所以在你的情况下你需要像这样查询:
SELECT Area, 'A_Percent' as Type, A_Percent as Val FROM YourTable
UNION ALL
SELECT Area, 'B_Percent' as Type, B_Percent as Val FROM YourTable
UNION ALL
SELECT Area, 'C_Percent' as Type, C_Percent as Val FROM YourTable
UNION ALL
SELECT Area, 'D_Percent' as Type, D_Percent as Val FROM YourTable
然后你应该有一个看起来更像这样的结果集:
Area Type Value
Area_1 A_Percent 50
Area_2 A_Percent 42
Area_3 A_Percent 20
Area_1 B_Percent 12
Area_2 B_Percent 28
Area_3 B_Percent 16
现在您可以在Matrix控件中使用它。将“区域”字段拖放到“列”组中。将Type字段拖放到'rows'组并将Value放入中间(将变为SUM()表达式)
全部完成:)