Thursday, September 15, 2011

Running totals per page in SSRS to display cumulative totals.

In Crystal Reports, you can easily make use of running totals on every page of your report. SQL Server Reporting Service does not have a standard functionality for this. Especially for companies who want to migrate from CRW to SSRS, running totals can be important to use. This blogpost will explain how you can implement running totals in your report.

  1. Add a tablix to your report and add a dataset to it. In my example I have 3 columns:
    Debtor code, Account Name and Outstanding amount.
  2. Add a 4th column to the tablix. Set the visibility of this column to Hide.
  3. Select in the 4th column the detail row. Select Text Box Properties and change the name of the textbox to 'RunningTotal'.
  4. Select Value and press the expression button. In this expression we will define the running total of the column. In my example, I have a columns Outstanding from the dataset 'CreditLimitDetails'

    =RunningValue(Fields!Outstanding.Value,SUM,"CreditLimitDetails")
    Now we have a running value of the outstanding amount in the 4th column.
  5. To display the running value on every page, we will use the page footer.
  6. Add a page footer to your report. In BIDS you can select, Report, Add Page footer.
  7. In this example I will add a page total and a running total to the report.
  8. Insert a 2 text boxes to the page footer.
  9. Open the expression definition of the first text box. In this text box we will define the totaal outstanding amount of the current page.
    ="Page Total: " + cstr(Sum(ReportItems!Outstanding.Value))
  10. Open the expression definition of the second text box. In this text box we will define the Running total of the outstanding column of the current page and all previous pages.
    ="Running Total: " +cstr(Last(ReportItems!RunningTotal.Value))
Now your report will print running totals at the bottom of every page.

9 comments:

Dany... said...
This comment has been removed by the author.
Dany... said...

Excellent information.
I have a doubt.
I could show the total of the previous page in the current pagnia? ...

I would appreciate your response...
thanks

Nima said...

Hi
that was greate and i used it in my reports (remote report).
but unfortunately it is not working for localReport.summaries dose not working when columns is hidden.
is there any work around?

Nima said...

Hi
that was greate and i used it in my reports (remote report).
but unfortunately it is not working for localReport.summaries dose not working when columns is hidden.
is there any work around?

Nima said...

Hi
that was greate and i used it in my reports (remote report).
but unfortunately it is not working for localReport.summaries dose not working when columns is hidden.
is there any work around?

Daniel R said...

running total would work when set column width size to 0

Andriuch said...

I want to show this parcial total in a footer of tablix, is possible?

nishita mahajan said...
This comment has been removed by the author.
nishita mahajan said...

It works fine in preview and after exporting it to PDF, but in word it does not show page totals on every page instead it shows the complete totals of the records.