我有同样的问题;这是我解决问题的方法。
以下是如何对本身就是求和函数的列进行小计。 SSRS 2005 不允许您聚合聚合函数。例如,显示运行总计的列的总计,在每日库存余额计算中很有用。
将以下代码添加到报告“Report”>“Properties”中
Dim public totalBalance As Decimal
Public Function AddTotal(ByVal balance As Decimal) AS Decimal totalBalance = totalBalance + balance return balance
End Function
Public Function GetTotal() return totalBalance
End Function
此代码添加两个变量:totalbalance 和 cnt 作为十进制数。还有两个函数AddTotal
and GetTotal
.
AddTotal
允许将行中的项目相加,在值单元格中按如下方式使用;
=RunningTotal(Fields!ColumnName.Value,sum,nothing)
with
=Code.AddTotal(RunningTotal(Fields!ColumnName.Value,sum,nothing))
在总单元格中,您无法简单地使用
=sum(RunningTotal(Fields!ColumnName.Value,sum,nothing))
use instead
=Code.GetTotal()
如果您需要对多个字段进行求和,只需添加更多变量和公共函数即可。
http://blog.wingateuk.com/2011/09/ssrs-aggregate-of-aggregate.html http://blog.wingateuk.com/2011/09/ssrs-aggregate-of-aggregate.html