Get previous,current and Next Record in ssrs report in a page

Manoj Pandey picture Manoj Pandey · Sep 8, 2016 · Viewed 7.1k times · Source

I am creating a report Which Show Previous,Current and Next id on Report. We can get Previous id via Preveious(Fields!Id.Value) but how can get next Id. Here is no function as Crystal report Next(Fields!ID.value) in ssrs. I am new in SSRS .Please suggest me solution ?

Here is screenshot to related this question

Answer

alejandro zuleta picture alejandro zuleta · Sep 8, 2016

I've created a sample dataset with the row number by category, in your case it should be by ID.

enter image description here

Add a tablix and use this expressions.

enter image description here

For the Next column use.

=Lookup(Fields!Row.Value+1,Fields!Row.Value,Fields!Category.Value,"DataSetName")

It produces:

enter image description here

Note that for the row number 1 there is no previous category so the cell is blank, the same condition is present for last row number which doesn't have a next category.

For your dataset it should be:

=Lookup(Fields!Row.Value+1,Fields!Row.Value,Fields!ID.Value,"DataSetName")

Replace DataSetName by your actual dataset name.

Let me know if this helps.