0

I'm trying to return a green YES if equal to 1, else return a red NO. Which means it equals 0. I found this which I think is helpful but can't figure out how to piece it together.SSRS - Conditional Text Formatting (Expressions using Switch)

The below gives me an error

IIF(Fields!SurveyCompleted.Value = 1, "Green", "Red")

Error 4 [rsFieldReferenceAmbiguous] The Value expression for the text box ‘Textbox12’ refers directly to the field ‘SurveyCompleted’ without specifying a dataset aggregate. When the report contains multiple datasets, field references outside of a data region must be contained within aggregate functions which specify a dataset scope.

I got the following to accidentally work to change the text when trying to change the color.

=First(IIF(Fields!UniqueReportRequests.Value = 1, "Yes", "No"),"RawCompletionScore")

How can I combine both to change the color and text? The color expression needs the dataset "RawCompletionScore" declared?

Community
  • 1
  • 1
user3749447
  • 299
  • 2
  • 5
  • 13

1 Answers1

2

Are you looking for this ..

=IIF(First(Fields!SurveyCompleted.Value, "RawCompletionScore") = 1, "Green", "Red")

Modified:

On your TextBox ..

enter image description here

Right mouse click and select Expression.

Enter your expression ..

=IIF(Sum(Fields!UniqueReportRequests.Value, "RawCompletionScore") = 1, "Yes", "No")

In the TextBox Properties, set your Background Color ..

enter image description here

=IIF(First(Fields!SurveyCompleted.Value, "RawCompletionScore") = 1, "Green", "Red")
Tak
  • 1,561
  • 1
  • 9
  • 8
  • This changes the text to "Green" for me. How can I change the color to green? Or even better, change the color to green AND text? – user3749447 Sep 02 '14 at 17:12
  • Modified the answer as this is what I believe you are looking for. – Tak Sep 02 '14 at 17:29
  • This makes sense but now I'm getting this error `Error 4 [rsFieldReferenceAmbiguous] The Color expression for the text box ‘Textbox12’ refers directly to the field ‘SurveyCompleted’ without specifying a dataset aggregate. When the report contains multiple datasets, field references outside of a data region must be contained within aggregate functions which specify a dataset scope. ` – user3749447 Sep 02 '14 at 17:40
  • Based on the error message you may be missing First() function around the field. Please show your code if you are still having an issue. – Tak Sep 02 '14 at 17:55
  • It was still picking up a lingering color expression that I deleted but somehow still existed. Thanks for the help! – user3749447 Sep 02 '14 at 17:59