JoshF91
JoshF91

Reputation: 139

SSRS Change cell color depending on SUM value

I am loading a dataset into my report and filling my last column with this expression: =Sum(Fields!ID.Value) and it loads fine, I am trying to put a condition in so when the number is less than 15 for example, the cell color will change to red. I have tried so many different syntax but nothing works... it must be pretty simple...? The errors I am getting are: The value expression for textbox has scope parameter that is invalid for aggregate

Any help would be good :)

Upvotes: 1

Views: 3842

Answers (2)

Ewan
Ewan

Reputation: 1087

This shows how you could add a colour range if necessary by using the Color property to set the font colour.

=iif(Sum(Fields!ID.Value) < 15,"Red",iif(Sum(Fields!ID.Value)>50,"Blue","Black"))

To Change the background colour instead you would use the Background colour property.

 =iif(Sum(Fields!ID.Value) < 15,"Red", "No Color")

Note that SSRS 2008 "Transaparent" is replaced by "No Color". Whilst transaparent works it gives rise to this warning message.

[rsInvalidColor] The value of the BackgroundColor property for the textbox ‘textbox22’ is “Transparent”, which is not a valid BackgroundColor.

As an alternative to these use "#FFFFFF" instead of Transaparent or No Color

Upvotes: 1

Mahesh
Mahesh

Reputation: 8892

To set the background color Click on the cell and in properties window on your right hand select the BackgroundColor property and then set expression to that property.
Or right click on cell and select TextboxProperties -> Fill and at the start there is option to set the expression for fill color. You are using the wrong expression the expression should be ,

  = IIF(Sum(Fields!ID.Value) < 15,"Red","Transparent")

You can change the Transparent to whatever color you want.Take a look here on how to use expressions.

Upvotes: 4

Related Questions