ssrs-2012reportbuilder3.0report-builder2.0

Conditional Formatting with switch


This is the design view of my matrix, it uses a series of datasets and the expressions use a lookup

enter image description here

This is the report when it has ran. I want to add some conditional formatting to the end column

enter image description here

The conditional formatting is dependent on the name of the person and then what total is in that field. Below is what I have tried. I would expect only Hilary's cell to show a colour. However others are appearing as green.

 =switch(Fields!Name.value = "Hilary" and 
  reportitems!Textbox62.value >=0 and reportitems!Textbox62.value <= 9,"#fd6767", 
  reportitems!Textbox62.value >=10 and reportitems!Textbox62.value <=19, "#f8d3a9", 
  reportitems!Textbox62.value >= 20 and reportitems!Textbox62.value <=100,"LightGreen")

enter image description here


Solution

  • If I understood correctly, all other names should get the cell with a blank background, shouldn't they ? In this case, you have to add the condition "Name=Hilary" for each row. In your expression, this one is just related to the first row. Try this one:

    =switch(
      Fields!Name.value = "Hilary" and reportitems!Textbox62.value >=0 and reportitems!Textbox62.value <= 9,"#fd6767", 
      Fields!Name.value = "Hilary" and reportitems!Textbox62.value >=10 and reportitems!Textbox62.value <=19, "#f8d3a9", 
      Fields!Name.value = "Hilary" and reportitems!Textbox62.value >= 20 and reportitems!Textbox62.value <=100,"LightGreen")