custom background color per row

vbnetcoder
vbnetcoder used Ask the Experts™
on
I have a table that is connected to a dataset that will return 5 and only 5 items every time.  The background color for each row needs to be different so the first item will be red, the second will be orange, the third purple etc.

How do i do this?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
SQL Server Data Dude
Most Valuable Expert 2013
Author of the Year 2015
Commented:
Try something like this  (Textbox, Right-click:Text Box Properties, Fill, click the Fill Color Expression button) ...
=IIF(RowNumber("your_tablix_name") = 1, "Red", 
   RowNumber("your_tablix_name") = 2, "Orange",
   RowNumber("your_tablix_name") = 3, "Purple", 
   RowNumber("your_tablix_name") = 4, "Mauve", 
   RowNumber("your_tablix_name") = 5, "Green")))))

Open in new window

Author

Commented:
I ended up using a switch but the concept was the same
Jim HornSQL Server Data Dude
Most Valuable Expert 2013
Author of the Year 2015

Commented:
Can you post your Switch code?  Kinda curious.

And a screen shot of your report with all the colors.  I have occasional debates with other experts on how many colors should be used in a report, especially with those experts that have embraced the new metrosexual 'minimalist' look.

Thanks.
OWASP: Threats Fundamentals

Learn the top ten threats that are present in modern web-application development and how to protect your business from them.

Author

Commented:
I can't post the report  because i would get in trouble with my client.  The table i was talking about earlier was a table HOWEVER i was using the table as a legend for a chart.  So, the first column was a square with the background using the switch statement and the second column was a description

I had to change to script a little so that i could share it but this gives the idea:

=SWITCH(RowNumber("dsTable1") = 1, "Green"),
RowNumber("dsTable1") =   2, "Blue"),
RowNumber("dsTable1") =  3, "Gray"),
RowNumber("dsTable1") =  4, "Green"),
RowNumber("dsTable1") =  5, "Red")
Jim HornSQL Server Data Dude
Most Valuable Expert 2013
Author of the Year 2015

Commented:
Ok thanks.
ValentinoVBI Consultant
Most Valuable Expert 2011

Commented:
Looking at Jim's solution I think he meant to use Switch but typed IIF instead (IIF doesn't work like that) :)

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial