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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

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 

The issue you're experiencing in Power BI Report Builder with the SWITCH expression not applying the expected background color to certain values like "Blocked" is most likely due to hidden data inconsistencies, such as trailing or leading spaces, case mismatches, or even invisible characters in your dataset.

 

Although the text "Blocked" may appear correct visually, the actual value in the field could include extra spaces or different casing (e.g., "Blocked ", " blocked", or similar), which causes the SWITCH expression to fail at matching it. To resolve this, it's recommended to wrap the field in TRIM() to remove any extra spaces and UCASE() or LCASE() to normalize casing within your expression.

 

Additionally, always include a default case in your SWITCH statement to handle unmatched values gracefully. For example, using SWITCH(UCASE(TRIM(Fields!Status.Value)), "ON TRACK", "Green", "AT RISK", "Yellow", "BLOCKED", "Red", "Transparent") ensures consistent results.

 

You can also create a temporary output to display the exact string and its length to visually confirm any hidden characters. These measures should help ensure that your conditional formatting applies correctly across all intended values.

 

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
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.