在表列值的总和 - RDLC报告总和、报告、表列值、RDLC

2023-09-06 10:13:26 作者:人潮拥挤我好多余

我在RDLC报告与6列和数据集的表。 DLL是加(参照)的报告,名为RepHlpr.dll。这个DLL有一个共同的功能的 GetPar 的计算并从其它数据库获取数据。列的金额的是工作的罚款,并获取数据按除权pression,作为:

I have a Table in Rdlc report with 6 Columns and a dataset. A dll is added ( referenced ) to the Report, named RepHlpr.dll. This dll have a shared function GetPar which calculates and gets data from other databases. Column Amount is working fine and getting data as per the expression, As :

尽管取得了的铜和 HP 的总和,一切工作正常,因为这些列中获取值的数据集。 我收到的问题来获得的值的和金额的。我已经试过前pressions:

While getting Sum of Copper and HP, Everything Works fine because these column gets values from dataset. I am getting problem to get Sum of Values of Amount. I have tried Expressions :

=Sum(Textbox44.Value)
=Sum(ReportItems!Textbox44.Value)
=Sum(Table1.Textbox44.Value)

但其示值误差:Textbox48(其中上述前pression为codeD)上使用报表项聚合函数。集合函数只能包含在页眉和页脚的报表项目使用。 有没有什么办法让列总和的金额的?

But Its showing Error : Textbox48 ( in which above expression is coded ) uses an aggregate function on a report item. Aggregate functions can be used only on report items contained in page headers and footers. Is there any way to get Sum of Column Amount ?

推荐答案

您可以在您的文本框,而不是试图将它放在文本框的值的公式​​适用总和

You can apply Sum on your formula of that textbox instead of trying to apply it on the value of textbox:

=Sum(Code.YourMethod(Fields!Filed1.Value, Fields!Filed2, otherParam), "YourDataSetName")

例如,如果你的报表数据集的名称是数据集1

For example if name of your report data set is "DataSet1"

Sum(RepHlpr.RepHlpr.GetPar("Amt", Fields!hp.Value, Fields!make.Value), "DataSet1")

示例

我创建了一个 code 功能:

Public Function Multiply(ByVal value As Integer, factor As Integer) As Integer
    Return value * factor
End Function

然后,我设置的前pression我的未绑定的数据额外的列:

Then I set expression for my extra column that is not data bound:

=Code.Multiply(Fields!Price.Value, 2)

然后,我添加了一个文本框,并设置其总和 EX pression根据我的自定义列前pression:

Then I added a TextBox and set its Sum expression based on my custom column expression:

=Sum(Code.Multiply(Fields!Price.Value, 2), "DataSet1")

这里是截图:

And here is the screenshot: