locked
adding serial number to grouping column in SSRS Tablix RRS feed

  • Question

  • Hi All,

    Kindly please help me add sr.n0 to grouping column in SSRS Tablix

    Wednesday, January 26, 2011 7:44 AM

Answers

  • Hi, Please try the below

    1. Open the report properties (right click on blank area outside the layout and click properties) or (Menu-->Report-->Report Properties)

    2. Click on the code pane on the left

    3. In the code window enter below script

    dim Counter as integer=0
    
    public function getGroupCounter() as Integer
     Counter=Counter+1
     return Counter
    end function
    

    4. Go to the properties of the group (based on which group you need the group serial number)

    5. Click the variables tab on the left

    6. Click on Add and set Name as GroupCountValue and set the expression (in the expression window) as =Code.getGroupCounter, click ok and close the window.

    7. Now in the textbox where you want to display the group number, set the expression as =Variables!GroupCountValue.Value

    8. Run the report and observe the result

    Hope this helps. Please feel free to discuss if further help required.


    Please click "Mark as Answer" if this resolves your problem or "Vote as Helpful" if you find it helpful.

    BH

    • Marked as answer by Prince Kher Wednesday, January 26, 2011 11:32 AM
    Wednesday, January 26, 2011 8:13 AM
  • Hi,

    Glad to note it helped you. For your background alternate color, please try below expression

    =iif(Variables!GroupCountValue.Value mod 2=0,"AntiqueWhite","Snow")
    
    
    

    You can use any of the preferred colors instead of the above color shown (AntiqueWhite and Snow) for example.

    Hope this helps

     

     


    Please click "Mark as Answer" if this resolves your problem or "Vote as Helpful" if you find it helpful.

    BH

    • Marked as answer by Prince Kher Wednesday, January 26, 2011 12:30 PM
    Wednesday, January 26, 2011 12:10 PM

All replies

  • Take a look at ROWNUMBER function

    http://msdn.microsoft.com/en-us/library/ms159225.aspx


    Best Regards, Uri Dimant SQL Server MVP http://dimantdatabasesolutions.blogspot.com/ http://sqlblog.com/blogs/uri_dimant/
    Wednesday, January 26, 2011 8:13 AM
  • Hi, Please try the below

    1. Open the report properties (right click on blank area outside the layout and click properties) or (Menu-->Report-->Report Properties)

    2. Click on the code pane on the left

    3. In the code window enter below script

    dim Counter as integer=0
    
    public function getGroupCounter() as Integer
     Counter=Counter+1
     return Counter
    end function
    

    4. Go to the properties of the group (based on which group you need the group serial number)

    5. Click the variables tab on the left

    6. Click on Add and set Name as GroupCountValue and set the expression (in the expression window) as =Code.getGroupCounter, click ok and close the window.

    7. Now in the textbox where you want to display the group number, set the expression as =Variables!GroupCountValue.Value

    8. Run the report and observe the result

    Hope this helps. Please feel free to discuss if further help required.


    Please click "Mark as Answer" if this resolves your problem or "Vote as Helpful" if you find it helpful.

    BH

    • Marked as answer by Prince Kher Wednesday, January 26, 2011 11:32 AM
    Wednesday, January 26, 2011 8:13 AM
  • Thanks alot.....

     

    Can you help me on 1more thing n,based on the grouping we did, I need to mark background colour With alternate rows showing diff colours....

     

    Wednesday, January 26, 2011 11:46 AM
  • Hi,

    Glad to note it helped you. For your background alternate color, please try below expression

    =iif(Variables!GroupCountValue.Value mod 2=0,"AntiqueWhite","Snow")
    
    
    

    You can use any of the preferred colors instead of the above color shown (AntiqueWhite and Snow) for example.

    Hope this helps

     

     


    Please click "Mark as Answer" if this resolves your problem or "Vote as Helpful" if you find it helpful.

    BH

    • Marked as answer by Prince Kher Wednesday, January 26, 2011 12:30 PM
    Wednesday, January 26, 2011 12:10 PM
  • Bilal, I am trying to follow your steps above, but for me when I try to call the function (getGroupCounter) it gives an error saying "Unrecognized identifier". I am following the steps exactly as you have mentioned. Do you have any clue as to why i could be getting that error?
    Friday, June 3, 2011 1:49 PM
  • I checked it again; it is working well. Make sure you are using the correct casing (upper/lower cases) in function name and in the expression that calls the function.

     

     


    Please click "Mark as Answer" if this resolves your problem or "Vote as Helpful" if you find it helpful.

    BH

    Saturday, June 4, 2011 4:58 AM
  • I followed your procedure but in my report group properties the variable not detecting the expression Code.getGroupCounter ,showing red lines uder the getGroupCounter .And same is happing for textbox properties..

    Do i have to give any reference or any thing i missed ..

    please followup my issue..

    Tuesday, March 13, 2012 8:34 AM
  • this is the solution i am using in my report.

    in my report i have one group called "HeaderID". i want serial number 1 to 'n' for each header group.

    eg.

    header 123

       1 a 3

       2 b 5

       3 c  6

    header 234

       1 d 3

       2 e 5

       3 f  6

    give the below expression in your field

    =RunningValue("AnyName",Count,"YourGroupName")

    (in my case =RunningValue("Count",Count,"HeaderID")


    Wednesday, August 13, 2014 2:36 PM
  • Thank you,

    Very Helpful

    Tuesday, April 24, 2018 6:28 AM
  • working thanks.
    Monday, July 29, 2019 9:25 AM