locked
RDLC report to show total of a column RRS feed

  • Question

  • User1182587605 posted

    Hi,

    I have an RDLC report(tabular) and I need to show the total of a column named Total in my report. My code to fetch data is:

    protected void btnCreateReport_Click(object sender, EventArgs e)
            {
                try
                {
                    ReportViewer1.Visible = true;
                    string FromSite = DropDownList1.SelectedItem.Text.ToString();
                    string FromDate = txtSelectDate1.Text;               
                    string ToDate = txtSelectDate2.Text;               
                    string query = "select Dump_Date as Date,Dump_Num as DumpNum,ItemID,SiteID,Qty,Cost,cast(SUM(CAST(Qty as decimal(14,4))*cast(Cost as decimal(14,4))) as decimal(14,2)) As Total from IC_Dump_T where SiteID = '" + FromSite + "' and Dump_Date between '" + FromDate + "' and '" + ToDate + "' group by Dump_Date,ItemID,SiteID,Dump_Num,Qty,Cost";
                    ReportViewer1.ProcessingMode = ProcessingMode.Local;
                    ReportViewer1.LocalReport.ReportPath = Server.MapPath("~/DumpReport.rdlc");
                    RptDump dsdump = GetData(query);
                    ReportDataSource datasource = new ReportDataSource("RptDump", dsdump.Tables[0]);
                    ReportViewer1.LocalReport.DataSources.Clear();
                    ReportViewer1.LocalReport.DataSources.Add(datasource);
                }
                catch (Exception ex)
                {
                    lblMessage.CssClass = "alert alert-warning";
                    lblMessage.Text = "Msg 014: Please choose a valid date range";
                }
            }

    Now, I need to show the total of Total column. I have tried the expression:

    =Sum(Fields!Total.Value)

    but I have got a blank row but not the total of the column. Please help me show the sum for this report. My Column has decimal values in it and I need the total to show decimal values as well.

    Thanks,

    Deepak
     

    Wednesday, January 4, 2017 4:23 PM

All replies

  • User-2057865890 posted

    Hi Deepak,

    To display Tablix data region grand totals and group subtotals, use the shortcut Add Total command. The Add Total command is context-sensitive. For a cell in the row group area, the Add Total command automatically adds a row outside the group for totals. Take a look at https://technet.microsoft.com/en-us/library/bb630415(v=sql.100).aspx (Understanding Default Scope).

    Best Regards,

    Chris

    Thursday, January 5, 2017 8:36 AM