Search code examples
matrixdynamicreporting-services

SSRS: Add column number in matrix


I am creating a matrix to show salary breakdown of employees in Matrix. Since salary components are dynamic and can vary employee to employee, I used matrix. The matrix will look similar to the following

Employee Code Employee name Basic HRA Travel Allowance Special Allowance Total
1 2 3 4 5 6 7
07686 Alex 5687.00 657.00 102.00 6446.00
08761 Nick 5375.00 650.00 205.00 6230.00

Please note the row with the serial number in the above table is part of table header. Basic, HRA, Travel Allowance, Special Allowance are columns of matrix (dynamic). There can be even more salary components. Rest of the fields like Employee Code, Employee Name and Total are static fields.

The problem I am facing is to show the column serial number. Need help to generate and show the serial number dynamically.

Thanks in advance.


Solution

  • You can add the following custom code in your report

    Dim columnCount As Integer= 0
    
    Public Function columnNumber() As Integer
    
    columnCount = columnCount + 1
    Return columnCount
    
    End Function
    

    Use the function in the required columns enter image description here

    enter image description here