报表生成器中包含 CountDistinct 表达式的结果总和



我有一个报告,需要计算事件发生的天数。我创建了一个计算字段来清除日期:

=IIF(Fields!ID_ACW.Value > 0, Fields!CallDate.Value, Nothing)

通过将其放在 CountDistinct 表达式中,每行显示此事件发生的不同天数的正确数。

但是,我需要将这些结果加在一起,用于每个行组的总数。我试过使用

=Sum(CountDistinct(=IIF(Fields!ID_ACW.Value > 0, Fields!CallDate.Value, Nothing)))

=RunningValue(CountDistinct(=IIF(Fields!ID_ACW.Value > 0, Fields!CallDate.Value, Nothing)),Sum, "DataSet1")

,但都没有给我正确的总数。我是否遗漏了什么,或者是否可以添加一个表达式来汇总每行的值?

我能够通过将行组的值添加到计算字段中的日期来使其工作,如下所示:

=IIF(Fields!ID_ACW.Value > 0, Fields!CallDate.Value & " " & Fields!CallHour.Value, Nothing)

现在我可以使用'''CountDistinct(ACWDay('''并在所有行组中获得正确的总计。

有没有更干净的方法来做到这一点?

这是来自内存,所以它可能不是 100%,但你应该明白......

=Sum(
CountDistinct(=IIF(Fields!ID_ACW.Value > 0, Fields!CallDate.Value, Nothing), "YourRowGroupName")
)

基本上,您需要在每个行组中执行 CountDistinct 运算,然后对结果求和。

最新更新