Raju
Raju

Reputation: 86

How can i get RowNumber Matrix in SSRS Report

i am creating a matrix report. need to show row number in the Matrix table under column and row grouping, like this

     A   B   C

X    1   1   1

Y    2   2   2

Z    3   3   3

Presently i am using this Expression for Row number but i am getting incorrect count.

=RunningValue(CountDistinct("YourTableName"),Count,"YourTableName")

Upvotes: 1

Views: 9222

Answers (3)

Martin
Martin

Reputation: 155

What worked for me for a matrix with both row and column grouping is:

=RowNumber("YourColumnGroupName") / CountRows()

Upvotes: 0

sǝɯɐſ
sǝɯɐſ

Reputation: 2528

Riddle-Master has a decent answer if your matrix is 100% full, ie there are no empty cells.

RowNumber("DataSet1") will contain the running sum of all fields

RowNumber("RowGroup") will contain the number of fields in each row group

However, if you have empty cells, you'll end up with some fractions and staggered numbers.

I found what I believe to be a better answer on this site, as long as you have a value in each row that is unique from the last. In my case, I'm using Customer_Num.

Go to Report Properties, open the Code property and paste the following code:

public dim LastNum as String
public dim rowCount as int32 = 0

Public Function GetRowNum(byval Num as String) as Integer    
      if Num <> LastNum then
            rowCount = rowCount + 1
            LastNum = Num 
      End If
      Return rowCount
End Function

Then in the cell where you want the Row Number, past the following expression:

=Code.GetRowNum(Fields!Customer_Num.Value)

This should compare each value against the previous for each row, and give you an incrementing row number, no matter how many cell values are in each row.

Upvotes: 1

mRiddle
mRiddle

Reputation: 214

From my experience RowNumber alone would give the sum all the dynamic fields from every row.

But a RowNumber with a scope on one field only would give the sum of the dynamic fields on one row alone.

Thus what solved it for me was:

=RowNumber("DataSet1")/RowNumber("StudentId")

When DataSet1 is from where I take all my matrix info and StudentId is only one of the fields in a row.

Upvotes: 0

Related Questions