[英]Dynamic Grouping in SSRS 2012
I am developing a report that have parameter like 我正在开发具有以下参数的报告
RowGroupLevel1, RowGroupLevel1,
RowGroupLevel2, RowGroupLevel2,
ColumnGroupLevel1, ColumnGroupLevel1,
ColumnGroupLevel2, ColumnGroupLevel2,
ColumnGroupLevel3 ColumnGroupLevel3
Row Group Contain Category, Executive Name, Client Name Like Field Column Group Contain Year,Quarter,Month Field. 行组包含类别,执行名称,客户名称(如字段)列组包含Year,Quarter,Month字段。
So My requirement is as like except Level1 in Row and Column Grouping other fields are optional. 因此,我的要求与“行和列分组”中的“级别1”相同,其他字段是可选的。
For An Example : if I am selecting as below 例如:如果我选择如下
scenario 1 : 方案1:
RowGroupLevel1 - Category RowGroupLevel1-类别
RowGroupLevel2 - Executive Name RowGroupLevel2-执行名称
ColumnGroupLevel1 - Year ColumnGroupLevel1-年
ColumnGroupLevel2 - Quaker ColumnGroupLevel2-Quaker
ColumnGroupLevel3 - Month ColumnGroupLevel3-月
scenario 2 : 方案2:
RowGroupLevel1 - Category RowGroupLevel1-类别
RowGroupLevel2 - RowGroupLevel2-
ColumnGroupLevel1 - Year ColumnGroupLevel1-年
ColumnGroupLevel2 - Month ColumnGroupLevel2-月
ColumnGroupLevel3 - ColumnGroupLevel3-
so as per above scenario how I can grouping my report dynamically. 因此,按照上述方案,我可以如何动态地对报告进行分组。
Please help me to create any type of SSRS report. 请帮助我创建任何类型的SSRS报告。
Thanks in advance. 提前致谢。 Ankit Gusani
安吉·古萨尼(Ankit Gusani)
The easiest way to achieve this is to first of all write your query which pulls forward the results like this. 实现此目的最简单的方法是,首先编写查询,以将结果向前拉。
SELECT DATEPART(WEEK, Date_Column) AS [Weekly]
,DATEPART(MONTH, Date_Column) AS [Monthly]
,DATEPART(YEAR, Date_Column) AS [Yearly]
,SUM(Some_Column) AS Total
FROM Table_Name
GROUP BY DATEPART(MONTH, Date_Column)
,DATEPART(WEEK, Date_Column)
,DATEPART(YEAR, Date_Column)
Add a Matrix Data region. 添加一个矩阵数据区域。 Drag and drop
Total
column to DATA
. 将
Total
列拖放到DATA
。
Create a Parameter say GROUP ON
of Text
type, and provide values 创建一个
Text
类型为GROUP ON
的参数,并提供值
1) Weekly
2) Monthly
3) Yearly
Now below in ROW GROUPS
pane, right click the only visible Row Group and goto GROUP PROPERTIES
In GROUP ON
section put following expression. 现在,在下面的“行
ROW GROUPS
窗格中,右键单击唯一可见的行组,然后转到“ GROUP ON
GROUP PROPERTIES
部分,将其放在下面的表达式中。
=SWITCH(
Parameters!Groupby.Value = "Weekly", Fields!Weekly.Value
,Parameters!Groupby.Value = "Monthly", Fields!Monthly.Value
,Parameters!Groupby.Value = "Yearly", Fields!Yearly.Value
)
Use the exactly same Expression on Data region ROWS
section. 在数据区域
ROWS
部分使用完全相同的表达式。
For Column name you can use the following Expression... 对于列名,您可以使用以下表达式...
=SWITCH(
Parameters!Groupby.Value = "Weekly", "Weekly"
,Parameters!Groupby.Value = "Monthly", "Monthly"
,Parameters!Groupby.Value = "Yearly", "Yearly"
)
and you are good to go. 而且你很好。
Important Note 重要的提示
SSRS is a cool tool for data presentation, not so cool when it comes to Data manipulation, to get better performance do all sorts of Data Manipulation closer to source (database, SQL Server). SSRS是用于数据表示的一种很酷的工具,但在数据处理方面却不那么酷,为了获得更好的性能,请执行各种更接近源(数据库,SQL Server)的数据操作。
All of the presentation stuff should be handled on SSRS. 所有演示材料都应在SSRS上处理。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.