SSRS Previous Function

The SSRS Previous Function is an aggregate function that returns the previous value from the given field. You can use it to test or compare the current value with the previous. This article explains using the SSRS Previous Function to find the preceding value or text in a particular group or complete table with an example.

The syntax of the SSRS Previous Function to find the value or text before in a Default scope is as shown below.

Previous(Fields!SalesAmount.Value)
Previous(Fields!FirstName.Value)

To demonstrate the SSRS Previous Function, we use the Employee table below, which has 15 records grouped by Occupation. The image below shows the records in the First Table report.

Aggregate Source

SSRS Previous Function Example

For this, let me add a new column to the right side of the Income and name the header as the Previous Income. Next, right-click the textbox and choose the Expression. To understand the report, I suggest you refer to the Charts, Table, Grouping, and Format Table articles in SSRS.

Choose the Textbox expression option

It opens the following expression window to write the Previous function. The code below returns the Previous Income value.

=Previous(Fields!YearlyIncome.Value)
SSRS Previous Function Expression to find the income before

Similarly, add a new column to the right side of the Sales to return the previous sales. The SSRS Previous Function Expression is as shown below.

=Previous(Fields!Sales.Value)

Please click the preview tab to see the Employee’s Previous yearly income and Sales value. If you observe the report, the first rows are empty because there is a previous record. For more functions >> Click Here!

SSRS Previous Function preview

Let me create two more new columns for performing arithmetic operations on the current value against the previous values. The expression below subtracts the previous income from the current income.

=Fields!YearlyIncome.Value - Previous(Fields!YearlyIncome.Value)
SSRS Previous Function expression for Arithmetic operations

Similarly, the following SSRS Previous function expression subtracts the previous sale from the current sales value.

=Fields!Sales.Value - Previous(Fields!Sales.Value)

The report below shows the Previous income and sales along with the subtractions.

SSRS Previous Function Report preview