Q:

How to get the previous value of a row in SSRS

My SSRS report has two groups (Account, Month). Account is Parent and Month is child group. Now I want to show the ending balance of each Month as the Beginning balance of next month. A sample report is given bellow. Red font indicates the SUM of each group. Remember that i am trying to get the result by using SSRS Previous() function, but can't get the expected result. 
Previous(Sum(Fields!NetAmt.Value),"Month")

Month => Month group name.
Can any one help me? 
Thanks in advance.
Rashed
Sample SQL Data
CREATE TABLE [dbo].[Balances](
    [id] [int] IDENTITY(1,1) NOT NULL,
    [Account] [nvarchar](50) NULL,
    [Month] [date] NULL,
    [BegBalance] [float] NULL,
    [Debit] [float] NULL,
    [Credit] [float] NULL,
    [EndBalance] [float] NULL,
 CONSTRAINT [PK_Balances] PRIMARY KEY CLUSTERED 
(
    [id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET IDENTITY_INSERT [dbo].[Balances] ON
INSERT [dbo].[Balances] ([id], [Account], [Month], [BegBalance], [Debit], [Credit], [EndBalance]) VALUES (1, N'Cash', CAST(0xDB3A0B00 AS Date), 0, 100, 50, 50)
INSERT [dbo].[Balances] ([id], [Account], [Month], [BegBalance], [Debit], [Credit], [EndBalance]) VALUES (2, N'Cash', CAST(0xDB3A0B00 AS Date), 0, 200, 50, 150)
INSERT [dbo].[Balances] ([id], [Account], [Month], [BegBalance], [Debit], [Credit], [EndBalance]) VALUES (3, N'Cash', CAST(0xFA3A0B00 AS Date), 0, 200, 50, 150)
INSERT [dbo].[Balances] ([id], [Account], [Month], [BegBalance], [Debit], [Credit], [EndBalance]) VALUES (4, N'Cash', CAST(0xFA3A0B00 AS Date), 0, 200, 100, 100)
INSERT [dbo].[Balances] ([id], [Account], [Month], [BegBalance], [Debit], [Credit], [EndBalance]) VALUES (5, N'Mr.  Axxx', CAST(0xDB3A0B00 AS Date), 0, 200, 100, 100)
INSERT [dbo].[Balances] ([id], [Account], [Month], [BegBalance], [Debit], [Credit], [EndBalance]) VALUES (6, N'Mr.  Axxx', CAST(0xDB3A0B00 AS Date), 0, 100, 50, 50)
INSERT [dbo].[Balances] ([id], [Account], [Month], [BegBalance], [Debit], [Credit], [EndBalance]) VALUES (7, N'Mr.  Axxx', CAST(0xFA3A0B00 AS Date), 0, 100, 50, 50)
INSERT [dbo].[Balances] ([id], [Account], [Month], [BegBalance], [Debit], [Credit], [EndBalance]) VALUES (8, N'Mr.  Axxx', CAST(0xFA3A0B00 AS Date), 0, 100, 20, 80)
SET IDENTITY_INSERT [dbo].[Balances] OFF

After Using Previous() function

A:

You can use LOOKUPSET function and custom code to get the previous End Balance total.
Go to Report menu / Report properties... in the Code tab paste this VB function.
Public Function GetBegBal(values As Object) As String
    Dim total As Double = 0
    For Each value As Double In values
                      total = total + value
        Next
    Return total
End Function

In the Beg Balance use this expression:
=Code.GetBegBal(
LOOKUPSET(
Fields!Account.Value & "-" & MONTH(Fields!Month.Value)-1,
Fields!Account.Value & "-" & MONTH(Fields!Month.Value),
Fields!EndBalance.Value,
"DataSetName")
)

Replace DataSetName by the actual name of yours, then preview your report, it should look like this:

Note I am using MONTHNAME function in the Months column so it returns the name of the month based on the regional and language settings in my machine (Spanish).
Let me know if this helps.

