我有一个复杂的表达式,它根据账单类型计算收入。它基本上说如果 Bill type = Progress 使用 X 计算,如果 Bill type = NTE 使用 Y 计算,对于其他一切使用 Z。因为这是一个聚合,你不能简单地通过使用 SSRS 中的 sum 函数来总结总数。您需要使用自定义代码。我一直在使用我在 Stack 上找到的以下内容。见下文。
Public Shared Dim grandTotal as Decimal
Public Shared Dim costCenterTotal as Decimal
Public Shared Dim workerTotal as Decimal
Public Shared Function Initialize()
grandTotal = 0
costCenterTotal = 0
workerTotal = 0
End Function
Public Function AddTotal(ByVal b AS Decimal) AS Decimal
grandTotal = grandTotal + b
costCenterTotal = costCenterTotal + b
workerTotal = workerTotal + b
return b
End Function
Public Function GetWorkerTotal()
Dim ret as Decimal = workerTotal
workerTotal = 0
return ret
End Function
Public Function GetCostCenterTotal()
Dim ret as Decimal = costCenterTotal
costCenterTotal = 0
return ret
End Function
Public Function GetGrandTotal()
Dim ret as Decimal = grandTotal
grandTotal= 0
return ret
End Function
在我的主要表达式中,我将 code.AddTotal() 函数添加到表达式中,并且在总行中,我在列中使用了 code.GetGrandTotal() 函数。
问题是当我运行报告时,我在 Grand Total Line 中没有得到正确的总数。它似乎会根据我是否查看报告的每一页而改变,即使我查看所有页面,总计也不正确。好像要重置了。有人可以告诉我我做错了什么。谢谢。