Question

I have percentage calculated field and it has to have different color based on values:

  • where <70% is red
  • 70% to 79.9% is Yellow
  • 80%+ is green

I tried:

=Switch((Sum(Fields!TotalQtySUM.Value, "DataSet1")/Sum(Fields!REG_HOURS.Value, "DataSet1")) < 0.7, "Red" ,
    (Sum(Fields!TotalQtySUM.Value, "DataSet1")/Sum(Fields!REG_HOURS.Value, "DataSet1")) < 0.8, "Black",
    (Sum(Fields!TotalQtySUM.Value, "DataSet1")/Sum(Fields!REG_HOURS.Value, "DataSet1")) >= 1, "Green")

And:

=IIF((Sum(Fields!TotalQtySUM.Value, "DataSet1")/Sum(Fields!REG_HOURS.Value, "DataSet1")) < 0.7, "Red" ,"Green")

They either all red or change the colors randomly without following any rules Where did I go wrong?

Was it helpful?

Solution

I think your first operator is overriding your other operator: '< 0.7' is true for the color before '< 0.8'. Try to reverse the first two criteria and that may fix your issue. I ran into something similar to this and I believe this is how I fixed it. Also you don't need to do Sum(Fields!(Field).Value, "(Dataset)"), You can just do this: "Sum(Fields!(Field).Value)".

The second criteria you gave though I would test the value you are getting by itself. It seems the second set may be valid but the expression may not be what you are expecting. Also I would just add a 'computed' field to my dataset instead of doing it in an expression. This may be faster than the expression evaluation in the end. The more expressions you use in SSRS the slower the report becomes. I know when an expression does not work for setting a property I usually go through the parts piece by piece.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top