Wednesday, March 7, 2012

Conditional Formatting Question

I have a column that contains either a test score or the state abbreviation where the student passed a particular test. I want the text to be red between 100-159, green greater than or equal to 160 and black otherwise.

This is what I've tried to take care of the scores:

=IIf(Fields!Score.Value <= 159 and Fields!Score.Value > 100,"Red", "Green")

Two issues:
I want all other scores (< 100) to be Black and
I'm not sure how to deal with the state abbreviations. I'm assuming this is why I receive this error:

[rsRuntimeErrorInExpression] The Color expression for the textbox ‘Score’ contains an error: Input string was not in a correct format.
Preview complete -- 0 errors, 1 warnings

All data is stored as varchar.

Hello,

Yes, the reason you get that warning is because your field is stored as varchar. I think this will do what you want, you can add additional conditions for different colors.

=Switch(

IsNumeric(Fields!Score.Value) and cInt(Fields!Score.Value) >= 160, "Green",

IsNumeric(Fields!Score.Value) and cInt(Fields!Score.Value) > 100, "Red",

1=1, "Black"

)

Jarret

|||Thanks. That did it.

No comments:

Post a Comment