Crystal Reports & SQL Reporting Services Training Consultants
Account Log in:
Username:
Password:
For something called "common" sense, why is there so little of it around?
 
Institute of IT Trainers - Freelance Trainer of the Year 2006 & 2009
Liverpool Business Connect Member
  Maximum Impact Solutions Limited - Reporting Solutions, Creating Answers
Reporting Solutions - Creating Answers, Crystal Reports, Dashboarding (Xcelsius) & SQL Reporting Services

The Maximum Impact Solutions Blog Feed ME!!!!

22
July

How Do I return the Previous Row Value in SSRS 2017

A client contacted me regarding an issue of returning the previous row data in their SQL server reporting services 2017 report.


Solution:

SSRS has a function Previous(), that allows one to return the previous row value, well in principle.

As with most things with SSRS if your report is simple than these functions work fine, but as soon as you start adding groups into tables, or work with matrix, then things get a little more complicated.

In this case the report was based on a report with a number of groupings, and as good as SSRS is, one thing it's not is intuitive.



To resolve this issue,

=Previous(First(Fields!Fieldname.Value)

Using the First() function ensures that SSRS looks at the previous row  group

If you have any questions, leave us a comment below, or need any assistance, please do not hesitate to Contact Us
1

Nitish

07
May
How do we return the value in the row before the previous one?
2

Julia

07
May
Hi Nitish, Thank you for your enquiry.

Unfortunately there no is facility/function within SQL Server Reporting Services to do this directly.

However you can achieve this in your dataset, using the SQL LAG() function, along with the PARTITION by clause and then base you report on that:

LAG(TableName.FieldName, 2,0)

MAKE A COMMENT

Name *

Email Address *

Comment *

To prove you are human what is:

97 + 16 =