Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
Peppy_Le_Dew
New 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 expression which uses SWITCH to apply a background color to tablix cell based on some fields value.  What's weird is this expression seems to work 90% of the time, but there are some outliers which aren't working.

 

Here is the expression:

Peppy_Le_Dew_0-1700151391089.png

 

And here is a snip of the paginated report.  You can see it works for On Track, and (not shown below) it is also working for 'At Risk'.  But for this one 'Blocked' cell it doesn't seem to be working.

Peppy_Le_Dew_2-1700151507114.png

 

Adding to my confusion, I am using almost the same expression to populate the text to these cells in the first place, and as we can see this piece is working since the cell shows as 'Blocked'

Peppy_Le_Dew_3-1700151610250.png

 

 

This probably isn't enough context to point me straight to the issue, but wondering if anyone has ideas on what might cause this, or where I can check in my report.  Help is appreciated, thanks in advance!

3 REPLIES 3
rohit1991
Super User
Super 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.


Did it work? ✔ Give a Kudo • Mark as Solution – help others too!
SreeniBattula
Helper II
Helper II

# is missing in the color code "e81224" in the expression. it  should be "#e81224"

SreeniBattula_0-1748371898462.png

 

 

GeorgeColl
Helper II
Helper II

Appreciate this is beyond late, but I stumbled across this looking for some examples using the switch function and this was a top result. I noticed the issue so thought may aswell give the answer.

 

The hex value for the "Blocked" row was missing a # sign at the start of the hex value, hence not working for that one but working for the others.

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.