4

如果我有一个@Fruit允许多项选择的报表参数 ( ),我如何将该参数用作 SSRS 矩阵中的列组?

通常,我会在查询中使用该参数,如下所示:

WHERE tbl.fruit In ( @Fruit )

然后我将使用数据集中的列作为我的组。但是,在这种情况下,我需要返回完整的数据集。我无法过滤查询,但我仍然想只显示参数选择的组。如果我的查询返回 Apples、Oranges 和 Bananas,但参数只选择 Apples 和 Oranges,我的 tablix 应该只有 2 列。

我尝试将 Group By 表达式设置为=Parameters!Fruit.Value,但随后出现此错误:

用于对“ColumnGroup”进行分组的 Group 表达式返回的数据类型无效。(rsInvalidExpressionDataType)

我的参数类型是文本,我已经尝试过允许和不允许空白值。

4

1 回答 1

5

So it seems you want to filter a report object based on the selected values in a multi-value parameter, in the case @Fruit?

If, as you say, you can't apply the filter in the Dataset query/stored procedure, you can apply a filter at the tablix level like:

enter image description here

Where the expression is:

=IIf(InStr(Join(Parameters!Fruit.Value, ","), Fields!Fruit.Value)) > 0
  , "INCLUDE"
  , "EXCLUDE")

Basically this is using the JOIN function to get a comma-delimted list of selected values, then checking if the Fruit field in the object dataset is in that list; if it is, include it.

于 2013-07-18T23:12:01.467 回答