Matrix Row Number in SSRS 2005

How to generate row number 1,2,3,4,5,6,........... of matrix row in SSRS 2005
I am trying Row Number for serial number but its difficult. Following result is in matrix

SR No.      Roll Number            Registration Code            Student Name                              
1      AS01-2            110905003            ADKAR SHARDUL SURESH                              
2      AS01-3            110901002            ADMUTHE AJINKYA RAJENDRA                              
3      AS01-4            110913070            ADSUL PRANITA PRAKASH                              
4      AS01-5            110909028            AGRAWAL GOWARDHAN
5      AS01-6            110905005            AGRAWAL NITESH DATTULAL                              
6      AS01-7            110908004            AGRAWAL SHIVANG UMESH                              
7      AS01-8            110910144            AGRAWAL VINEET DINESH                              
8      AS01-9            110908001            AHER SAGAR GANPATRAO                              
9      AS01-10            110907050            AHIRE AKSHAY ANIL                              
Sandesh_IngawaleAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Sandesh_IngawaleAuthor Commented:
I am using matrix and this solution is for table. I want solution for matrix.
0
Tim HumphriesDirectorCommented:
Hi,

I think you may have to do this manually using code. Create an integer variable to count to rows and a 'Last Ser no' variable as a string.
At the start of the report call a function to initialise the row counter and the serial no variable.
In the matrix, add a column and insert a call similar to:

=Code.GetRowNo(Fields!SerNo)

The function GetRowNo will be something like:

Public Function GetRowNo(byval SerNo as String) as Integer

      if SerNo <> lastSerNo then
            rowCount = rowCount + 1
            LastSerNo = SerNo
      End If
      Return rowCount
End Function

This works in a test scenario.

Tim
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
10 Tips to Protect Your Business from Ransomware

Did you know that ransomware is the most widespread, destructive malware in the world today? It accounts for 39% of all security breaches, with ransomware gangsters projected to make $11.5B in profits from online extortion by 2019.

Sandesh_IngawaleAuthor Commented:
Hi Tim,
     I am using your function and its very good data will display as I want , but there is 1 Problem , when this report will export in Acrobat PDF OR display in print Layout that time it start with 71, I don't know why?

Sandesh
0
Sandesh_IngawaleAuthor Commented:
Hi Tim,
         Result of my report is in 70 Rows.
Thanks,
Sandesh
0
Tim HumphriesDirectorCommented:
Hi,

It sounds as though the report is being rerun in some way when you render it again. I can't recreate this problem in 2008.
What code do you have in your initialisation function, and where are you calling the initialisation function from?

Tim
0
Sandesh_IngawaleAuthor Commented:
Hi Tim,

          Please find attachment of report. This report is in excel. But when this same report is display in Pdf, the sr. No. Column is start from 71. I am attaching .pdf fiilr screen shot also.
 In design time I am using function that sent by you.

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

Public Function GetRowNo(byval SerNo as String) as Integer

      if SerNo <> lastSerNo then
            rowCount = rowCount + 1
            LastSerNo = SerNo
      End If
      Return rowCount
End Function

and in textbox exppression of matrix 1st column 2nd row is =Code.GetRowNo(Fields!StudentRegCode.Value)

Sandesh

SemesterwiseCreditRegistration.xls
Rep-1.JPG
0
Tim HumphriesDirectorCommented:
Ok, you don't seem to have a initialise function to reset the count.
Do the following:

Insert an additional function Initialise:

Public Function Initialise()
  rowCount = 0
  LastSerNo = ""
End Function

and then add a textbox to your report  - above the main table so it is executed first - with the expression = Code.Initialise(). This textbox can be hidden.

Then each time the report is rendered the variables should be reset.

Tim
0
Sandesh_IngawaleAuthor Commented:
Thank You very Much Tim, Now its working fine,

Thanks a lot.

Sandesh
0
Sandesh_IngawaleAuthor Commented:
Very good solution and it seems proper ans with in time.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server

From novice to tech pro — start learning today.