SWITCH is mostly working but randomly fails on something like “Blocked,” chances are it’s not the expression it’s the data.
A few things to check:
- Trailing spaces : the value might look like “Blocked” but actually be “Blocked ” (with a space).
- Case sensitivity : SWITCH is picky. “Blocked” ≠ “BLOCKED”
- Weird characters : I once had a value fail because of a hidden non-breaking space copied from Excel.
What worked for me was wrapping the field in TRIM() and sometimes even UCASE() like:
SWITCH(TRIM(UCASE(Fields!Status.Value)),
"BLOCKED", "Red",
"ON TRACK", "Green",
"AT RISK", "Yellow",
"GRAY"
)
Also, add a default return just in case it doesn’t match anything.
Lastly to debug it, just drop the raw field into a text box on the report and see what it actually says at runtime. That’ll usually tell you what’s up.