custom background color per row

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?
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Jim HornMicrosoft SQL Server Data DudeCommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
vbnetcoderAuthor Commented:
I ended up using a switch but the concept was the same
Jim HornMicrosoft SQL Server Data DudeCommented:
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.

Exploring SharePoint 2016

Explore SharePoint 2016, the web-based, collaborative platform that integrates with Microsoft Office to provide intranets, secure document management, and collaboration so you can develop your online and offline capabilities.

vbnetcoderAuthor 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 HornMicrosoft SQL Server Data DudeCommented:
Ok thanks.
ValentinoVBI ConsultantCommented:
Looking at Jim's solution I think he meant to use Switch but typed IIF instead (IIF doesn't work like that) :)
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.