Sum of Column Values in Table - Rdlc report

42,842

Solution 1

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")

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

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

Example

I created a Code function:

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

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

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

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:

enter image description here

Solution 2

Right click on table click insert row->outside group -below Right click on column that you want to take sum go to expression. In category select common function->aggregate then double click on sum in item, now double click select fields (dataset1) in values double click on columns that you want to take sum. Now at the top. =Sum(cdec(Fields!salary.Value)) In it salary is the column name in database. But cdec add manually.

Share:
42,842
Er Mayank
Author by

Er Mayank

Updated on March 20, 2020

Comments

  • Er Mayank
    Er Mayank about 4 years

    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 :

    Expression Value of Column

    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)
    

    Sum Of Amount Column


    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 ?

  • Er Mayank
    Er Mayank over 8 years
    why we can't do something like this =Sum(ReportItems!Textbox44.Value) ?
  • Reza Aghaei
    Reza Aghaei over 8 years
    I think becauseTextbox44 is not a member of Your DataSet1 and probably these aggregate functions only works on fields of your dataset.