每行不同的钻取

时间:2021-09-30 08:23:34

I have an SSRS report with several levels of drilling down. Data is aggregated up for the top level view, but I need to show a different drill down report depending on the type of one of the columns.

我有一份SSRS报告,其中有几个级别。数据汇总为*视图,但我需要显示不同的向下钻取报告,具体取决于其中一个列的类型。

Eg:

例如:

Table 1 - Apples

表1 - 苹果

Name     Cost
Fuji     1.5
Gala     3.5

Table 2 - Squashes

表2 - 南瓜

Name        Cost
Pumpkin     2
Gourd       4.5

I have a stored procedure which aggregates these and puts them in a table for the top level report to show. Ie:

我有一个存储过程聚合这些并将它们放在一个表中,以显示*报告。即:

Name         Cost     ItemType
Apples       5        1
Squashes     6.5      2

In reality, the two tables have different columns which I need to show in the drill through reports. Is it possible to look at the ItemType column and either drill down to one of two sub-reports, depending on it's value?

实际上,这两个表有不同的列,我需要在钻取报告中显示。是否可以查看ItemType列并深入查看两个子报告中的一个,具体取决于它的值?

2 个解决方案

#1


1  

If you need to choose between two or more different sub-reports then make the ReportName property of the action on the textbox an expression like this.

如果需要在两个或多个不同的子报表之间进行选择,请将文本框上操作的ReportName属性设置为这样的表达式。

=IIF(Fields!ItemType.Value = 1, "subReport_Apples", "subReport_Oranges")

if you have more than a handful SWITCH will probably be better

如果你有一把以上的SWITCH可能会更好

= SWITCH (
          Fields!ItemType.Value = 1, "subReport_Apples",
          Fields!ItemType.Value = 2, "subReport_Oranges",
          Fields!ItemType.Value = 3, "subReport_Lemons",
          True, "subReport_AnythingElse"
)

If you have a LOT of item types, consider adding the names of the subreports to your database creating a new table containing ItemType and subReportName. You can then join to this in your query and get the actual subreport name. The ReportName property of the text action would then simply be Fields!SubReportname.Value

如果您有很多项类型,请考虑将子报表的名称添加到数据库中,从而创建包含ItemType和subReportName的新表。然后,您可以在查询中加入此项并获取实际的子报表名称。然后,文本操作的ReportName属性将只是Fields!SubReportname.Value

#2


1  

You can add the ItemType as a parameter in your subreport(s). Then from your main report just link or jump to the sub report and pass along the Fields!ItemType.Value in the parameter configuration tab.

您可以将ItemType作为参数添加到子报表中。然后从主报表中链接或跳转到子报表,并在参数配置选项卡中传递Fields!ItemType.Value。

#1


1  

If you need to choose between two or more different sub-reports then make the ReportName property of the action on the textbox an expression like this.

如果需要在两个或多个不同的子报表之间进行选择,请将文本框上操作的ReportName属性设置为这样的表达式。

=IIF(Fields!ItemType.Value = 1, "subReport_Apples", "subReport_Oranges")

if you have more than a handful SWITCH will probably be better

如果你有一把以上的SWITCH可能会更好

= SWITCH (
          Fields!ItemType.Value = 1, "subReport_Apples",
          Fields!ItemType.Value = 2, "subReport_Oranges",
          Fields!ItemType.Value = 3, "subReport_Lemons",
          True, "subReport_AnythingElse"
)

If you have a LOT of item types, consider adding the names of the subreports to your database creating a new table containing ItemType and subReportName. You can then join to this in your query and get the actual subreport name. The ReportName property of the text action would then simply be Fields!SubReportname.Value

如果您有很多项类型,请考虑将子报表的名称添加到数据库中,从而创建包含ItemType和subReportName的新表。然后,您可以在查询中加入此项并获取实际的子报表名称。然后,文本操作的ReportName属性将只是Fields!SubReportname.Value

#2


1  

You can add the ItemType as a parameter in your subreport(s). Then from your main report just link or jump to the sub report and pass along the Fields!ItemType.Value in the parameter configuration tab.

您可以将ItemType作为参数添加到子报表中。然后从主报表中链接或跳转到子报表,并在参数配置选项卡中传递Fields!ItemType.Value。