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 DecimalIf Not runningTotals.ContainsKey(pageNumber) Then runningTotals.Add(pageNumber, pageTotal)For i As Integer = 1 To pageNumberElse runningTotals.Item(pageNumber) = pageTotal End If Dim total As Decimal = 0.00Return NothingIf runningTotals.ContainsKey(i) Then total += runningTotals.Item(i) Else End If Next i Return totalFor i As Integer = 1 To pageNumber - 1End Function Public Shared Function BroughtForward(ByVal pageNumber As Integer) As Decimal Dim total As Decimal = 0.00Return totalIf runningTotals.ContainsKey(i) Then total += runningTotals.Item(i) Else Return Nothing End If Next i End Function
=Code.BroughtForward(Globals!PageNumber)
=Code.CarriedForward(Globals!PageNumber, Sum(ReportItems!DatasetName.Value)