Forum Discussion
Peppy_Le_Dew
2 years agoNew Member
PowerBI Report Builder (Paginated) Switch Expression Issue
Hi All. This question/issue is concerning PowerBI Report Builder (or Paginated reports). Didn't see a sub-forum for that service so posting it here in Desktop. My issue is that I have an expres...
rohit1991
1 year agoSuper User
Hi Peppy_Le_Dew
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.