Showing posts with label total carried forward. Show all posts
Showing posts with label total carried forward. Show all posts

Tuesday, April 10, 2012

Total Carried Forward and Total Brought Forward in SSRS

Software : SQL Server Business Intelligent Development Studio 2008 | Reporting Services
Language : VB
Goal:
  • Get the total amount of particular column in a particular page (total carried forward) and display the amount to the next page (total brought forward).
Total to be carried in page 1

Bring the total in page 1 to be displayed in page 2 

Steps:
  • Click Report --> Report Properties --> Code
  • Copy and paste the custom code below:
    Dim Shared runningTotals As New Collections.Generic.Dictionary(Of Integer, Decimal)
    Public Shared Function CarriedForward(ByVal pageNumber As Integer, ByVal pageTotal As Decimal) As Decimal
    If Not runningTotals.ContainsKey(pageNumber) Then runningTotals.Add(pageNumber, pageTotal)
    For i As Integer = 1 To pageNumber
    Else runningTotals.Item(pageNumber) = pageTotal End If Dim total As Decimal = 0.00
    Return Nothing
    If runningTotals.ContainsKey(i) Then total += runningTotals.Item(i) Else End If Next i Return total
    For i As Integer = 1 To pageNumber - 1
    End Function Public Shared Function BroughtForward(ByVal pageNumber As Integer) As Decimal Dim total As Decimal = 0.00
    Return total
    If runningTotals.ContainsKey(i) Then total += runningTotals.Item(i) Else Return Nothing End If Next i End Function
  • Add a text box for your total brought forward in report header, and another text box for your total carried forward in report footer.
  • In order to call the function, use this following expression:
  • =Code.BroughtForward(Globals!PageNumber)
    =Code.CarriedForward(Globals!PageNumber, Sum(ReportItems!DatasetName.Value)