0

I have A tablex which has row grouping , trying to do some calculation base on the previous row in the group. so I tested Last(Fields!InQty.Value) and put it in the total cell. and it get the value of the same row :

enter image description here

When I tried Previous(Fields!InQty.Value) it get the value from the last row in the previous group :

enter image description here

so what is the way to get the previous value in the same group, also how to check if the row is the first in the group. Thank you.

Amr Ibrahim
  • 167
  • 3
  • 14
  • I have always assumed that the Previous function in SSRS had an optional scope parameter; alas, no. Shows how often I make use of it. You may have to think about doing this calculation in the dataset SQL. – R. Richards Mar 12 '17 at 14:21
  • https://social.msdn.microsoft.com/Forums/sqlserver/en-US/0251ad79-c1b9-4a34-a32f-64e5ea7561a1/runningvalue-in-a-matrix?forum=sqlreportingservices – Snowlockk Mar 13 '17 at 09:53

2 Answers2

0

This sounds like something you could just wrap inside an IF statement, perhaps as follows:

=IIF(Previous(Fields!ItemName.Value)=Fields!ItemName.Value,Previous(Fields!InQty.Value),Nothing)

...Or replace the Nothing with some constant if it's part of a larger calculation expression.

Wesley Marshall
  • 434
  • 4
  • 16
0

I think the best way in SSRS to do this is to use the RowNumber value for the group the cell is in (I'm calling it "Item" in the example below), and check that the RowNumber value for the group is greater than 1 before collecting the previous value. If it isn't greater than 1 you can put Nothing in the table cell:

=Iif(RowNumber("Item") > 1, Previous(Fields!InQty.Value), Nothing)
idclaar
  • 688
  • 2
  • 7
  • 17