-1

I have a SSRS table where there are three rows . First row is Category and Second Row is Subcategory . These fields are individual fields in database. The third row is the total . I need color formatting like below .

This is the structure of my table in SSRS .

enter image description hereenter image description here

  • Does this answer your question? [Add alternating row color to SQL Server Reporting services report](https://stackoverflow.com/questions/44376/add-alternating-row-color-to-sql-server-reporting-services-report) – StevenWhite Aug 06 '20 at 17:17

2 Answers2

0

For your Category and Total rows, just set the background color property as desired as these will not change.

For you subcategory rows set the background color property to something like

=IIF(RowNumber(Nothing) Mod 2 = 0, "Silver", "#F08080")

CHange the color names or hex values to match your required colours.

Alan Schofield
  • 13,594
  • 1
  • 15
  • 26
  • I used this expression but the problem I am facing here is there are three different field rows . So if I put this expression for first field row which is "category" as background color then the second field row which is "subcategory" background is not matching . Like if first row of category is Odd then show Silver else other color . The second row which is Subcategory can also have odd row number and will show same color as Silver as previous row. In this scenario the alternate color format will break . The color should be displayed according to previous row – Nishika Tamta Aug 07 '20 at 11:08
  • Edit your question and show your report design including row grouping. – Alan Schofield Aug 07 '20 at 12:33
0

Alternative is to put the following code in your report (Report Properties -> Code)

Public Function BackColour(Byval line as Decimal) as String
 
If line = -1
    return "Gainsboro"
End If
If line = -2
    return "LightGrey"
End If
If line = -3
    return "Silver"
End If
If line mod 2 = 0
    return  "#F08080"

Else
    return "White"
End If

End Function

Now if your inner most details group, set the background color to the following :

=code.backcolour(runningvalue(Fields!sub_category_code.Value,countdistinct,nothing))

Hope this gives you the result you are after

Harry
  • 2,135
  • 1
  • 14
  • 22