Reputation: 67
I'm trying to write a field expression for a Cell in my report where I have to change the string color of the cell depending on the string value in the cell.
Ex: if the column name as 'result' has a value 'FAIL'in it, the cell should show a Red color.
I tried the following:
=IIF(Fields!result.Value ="fail","red","green")
But It shows all fields in green color. please help
Thanks
Upvotes: 3
Views: 840
Reputation: 1958
Try adding a TRIM around your field:
=IIF(Trim(Fields!result.Value)="fail","red","green")
I often run into the same problem when trying to compare text values to literals due to value(s) in the database that were entered with leading or trailing whitespace. TRIM will remove both leading and trailing spaces, or you can use LTRIM for leading spaces only or RTRIM for trailing spaces only.
Upvotes: 3