SSRS Tablix或DB View中的条件组

时间:2013-01-24 17:29:51

标签: tsql ssrs-2008 ssrs-grouping

我创建了一个报告,应该使用Tablix对数据进行分组,如下所示:

Region  |  State  |  Customer  |  CustomerKey | Status
North   | NY      |  Bob       |  111         | VIP
        |         |  Mary      |  112         | VIP
        | MA      |  Bob       |  111         | Regular
        |         |  Tim       |  113         | Regular
East    | MD      |  Greg      |  114         | VIP
        | VA      |  Bob       |  111         | VIP
West    | CA      |  Greg      |  114         | Regular
        |         |  Mary      |  112         | VIP
        |         |  Sean      |  115         | Regular
        | WA      |  Sean      |  115         | VIP

这相对简单,因为我使用的视图包含所有相应的字段和关系,以便在tablix中进行分组。我的VIP客户遇到了问题。 在视图中,具有VIP状态的客户也具有具有常规状态的重复记录。例如,数据存储如下:

Region  |  State  |  Customer  |  CustomerKey | Status
North   | NY      |  Bob       |  111         | VIP
North   | NY      |  Bob       |  111         | Regular
North   | NY      |  Mary      |  112         | VIP
North   | NY      |  Mary      |  112         | Regular
North   | MA      |  Bob       |  111         | Regular
North   | MA      |  Tim       |  113         | Regular
East    | MD      |  Greg      |  114         | VIP
East    | MD      |  Greg      |  114         | Regular
East    | VA      |  Bob       |  111         | VIP
East    | VA      |  Bob       |  111         | Regular
West    | CA      |  Greg      |  114         | Regular
West    | CA      |  Mary      |  112         | VIP
West    | CA      |  Mary      |  112         | Regular
West    | CA      |  Sean      |  115         | Regular
West    | WA      |  Sean      |  115         | VIP
West    | WA      |  Sean      |  115         | Regular

我的SSRS报告因此显示如下数据:

Region  |  State  |  Customer  |  CustomerKey | Status
North   | NY      |  Bob       |  111         | VIP
        |         |            |              | Regular
        |         |  Mary      |  112         | VIP
        |         |            |              | Regular
        | MA      |  Bob       |  111         | Regular
        |         |  Tim       |  113         | Regular
East    | MD      |  Greg      |  114         | VIP
        |         |            |              | Regular
        | VA      |  Bob       |  111         | VIP
        |         |            |              | Regular
West    | CA      |  Greg      |  114         | Regular
        |         |  Mary      |  112         | VIP
        |         |            |              | Regular
        |         |  Sean      |  115         | Regular
        | WA      |  Sean      |  115         | VIP
        |         |            |              | Regular

如果用户具有VIP状态,我不关心他们的状态为常规状态(针对该特定地区/州)。无论如何我有条件地隐藏这些吗?提前致谢

1 个答案:

答案 0 :(得分:1)

就个人而言,我会考虑在第一个实例的数据库查询级别解决此问题。

也就是说,报告级别的一种方法是根据 Region State Customer <设置群组 / em>,然后在状态列中,您可以使用如下表达式:

=IIf(CountRows("CustomerGroup") = 2, "VIP", "Regular")

它有点笨重,但应该工作,因为看起来每个客户可以在地区/州级别有一行或两行 - 如果两个他们必须是VIP,并且因为你已经设置aa group你在每个 Region / State 组合中获得 Customers 的不同值。