Alternate Background Color in Rows

  • Hi,

    I am working on a report in the Reporting Services.  I was wondering if we can set alternate background color for a group of rows on the report.  Let's see the example below.

    ID     Name    Month   Field4   Field5

    1         A         Jan         8         9     --- Background color: red

    1         A         Jan         10       2     --- Background color: red

    1         A         May        3         3     --- Background color: transparent

    2         B         Feb         2         4     --- Background color: red

    3         C         Apr         5         6     --- Background color: transparent

    3         C         Apr         7         5     --- Background color: transparent

    4         D         Mar        2         2     --- Background color: red

    4         D         Jun         3         1     --- Background color: transparent

    The background color will be set based on the group of ID, Name and Month fields.  Does anyone know if this is doable?  If so, how to do it?

    Any help would be greatly appreciated!

    Thank you in advance.

    Wan

  • Hello!

    When you're trying to alternate the details, I use the following:

    = iif (rownumber(Nothing) mod 2, "White", "Gainsboro")

     

    When you're going off a group band, I use this:

    = iif (RunningValue( Fields!YourField.Value , CountDistinct, Nothing) mod 2, "White", "Gainsboro")

     

    Hope this helps....I ran into the same issue!

  • Hi!

    Thank you so much for your reply! 

    Your answer is exactly what I was looking for. 

    Wan

     

     

  • good code .. exactly what im looking for .. thnx ..

  • Hey all!

    I just ran into a little issue where you have two groups, and you'd need the 2nd grouping to alternate it's coloring.

    I used the following and it worked:

    = iif (RunningValue( Fields!grp1YourField.Value & Fields!grp2YourField.Value , CountDistinct, Nothing) mod 2, "White", "Gainsboro")

    Thanks!

  • Old post, I know, but I'm having difficulty implementing this solution. It works fine for the first few pages of the report, but then the color banding starts going haywire.

    I have Nurses and Patients. The report is grouped by Nurse, and Patient ID, but the columns displayed are Nurse, Patient NAME (not ID), and then details about the care. The grouping has to be by Patient Id because a nurse just might be taking care of two different patients with the same name (these are visiting nurses, not in-hospital or clinic).

    As I said, the alternating colors work fine for a few pages, but at some point (it varies by server/data set) the coloring gets confused, and stops alternating (in the attached image it's page 8. On another server with a different data set, it's page 4).

    I'm asking for thoughts on where to look, because it's so easy to debug SSRS.

    Thanks,

    Tom

  • what version of SSRS do you have?

  • 2008 R2

    Over the weekend had an inspiration (after digging out a piece of granite the size of a basketball from a hole 2 feet deep). I use custom code to keep track of the current and previous patient id. I'm curious to know why SSRS can't manage to do that!

  • Absolutley fantastic Sol_Web_Solutions! That script was an absolute winner!

  • How do I do to each group so one group row doesn't affect the other group?

    I used the following code: = iif (RunningValue( Fields!YourField.Value , CountDistinct, Nothing) mod 2, "White", "Gainsboro") but it continues even outside each group...

    Sol_Web_Solutions (9/10/2007)


    Hello!

    Whenyou're trying to alternate the details, I use the following:

    = iif (rownumber(Nothing) mod 2, "White", "Gainsboro")

    When you're going off a group band, I use this:

    = iif (RunningValue( Fields!YourField.Value , CountDistinct, Nothing) mod 2, "White", "Gainsboro")

    Hope this helps....I ran into the same issue!

Viewing 11 posts - 1 through 10 (of 10 total)

You must be logged in to reply to this topic. Login to reply