SSRS中具有指定范围的可用过滤器

时间:2013-05-30 07:34:02

标签: sql-server-2008 tsql ssrs-2008

我正在撰写报告中的图表。

由于我在CountId = 1的记录太多,我设置了一个显示可用值列表的过滤器,如下所示:

CountId:

  • 1
  • 2
  • 3
  • 4至6之间
  • 介于7至9之间
  • 10以上

如果我将可用值设置为1或2或3,则会显示结果,但我不知道如何为其间设置过滤器。

我想要一个像这样的过滤器 - 可用的过滤器是:

  • 1
  • 2
  • 3
  • 4
  • 大于5或大于等于5

1 个答案:

答案 0 :(得分:1)

你有很多运算符,所以也许你应该看一个基于表达式的过滤器来尝试处理这些不同的情况,例如:

表达式(类型Text):

=Switch(Parameters!Count.Value = "1" and Fields!Count.Value = 1, "Include"
  , Parameters!Count.Value = "2" and Fields!Count.Value = 2, "Include"
  , Parameters!Count.Value = "3" and Fields!Count.Value = 3, "Include"
  , Parameters!Count.Value = "4 to 6" and Fields!Count.Value >= 4 and Fields!Count.Value <= 6, "Include"
  , Parameters!Count.Value = "7 to 9" and Fields!Count.Value >= 7 and Fields!Count.Value <= 9, "Include"
  , Parameters!Count.Value = "Above 10" and Fields!Count.Value >= 10, "Include"
  , true, "Exclude")

<强>操作员:

=

<强>值:

Include

这假设一个字符串参数Count填充了上述值。

这可以通过计算参数和字段组合来生成常量IncludeExclude,然后显示返回Include的所有行。

正如评论中所提到的,很难完全按照你在这里提出的要求。我已经尽了最大努力,但如果您有更多问题,最好使用一些示例数据更新问题,以及您希望如何显示这些数据。