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

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

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
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.