Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
Hi everyone. I am using the switch statement for color formatting with this line of code. However, when it reaches to the same target amount, it doesn't excute the right formatting. What the code does it that if the actual meets or exceeds the target, the bg color will turn into green, if the actual meets atleast 90% of the target color will turn into yellow. the rest will turn into color red.
Now, the actual meets the exact target, the background supposedly turn into green but it doesn't. What did I missed? Thanks in advance.
% Productivity vs KPI Formmating =
SWITCH(
TRUE(),
[Productivity Percentage]>=[Productivity KPI],"#6aa84f", //GREEN
[Productivity Percentage]>[Productivity KPI] * .90,"#feda03", //YELLOW
"#bf211e" //RED
)
Solved! Go to Solution.
Hey @ronaldbalza2023 ,
from my perspective, the formatting measure works perfectly. I use exactly your definition, and this allows me to create the below table visual:
I created two very simple measures to represent the measures that are used inside the formatting measure:
Productivity Percentage = AVERAGE( 'Table'[Actual] ) Productivity KPI = AVERAGE( 'Table'[Target] )
and this one just to create a check inside the table:
Productivity Percentage 90 = AVERAGE( 'Table'[Target] ) * .9
Maybe, you can create a table showing the measures used inside the formatting measure. Be aware that this value (formatted by the UI) 55.0% does not equal the value 0.5501.
You need to format (adjust) the measure inside the DAX statement regarding the precision.
Hopefully, this provides some ideas on how to tackle your challenge.
Regards,
Tom
Hey @ronaldbalza2023 ,
from my perspective, the formatting measure works perfectly. I use exactly your definition, and this allows me to create the below table visual:
I created two very simple measures to represent the measures that are used inside the formatting measure:
Productivity Percentage = AVERAGE( 'Table'[Actual] ) Productivity KPI = AVERAGE( 'Table'[Target] )
and this one just to create a check inside the table:
Productivity Percentage 90 = AVERAGE( 'Table'[Target] ) * .9
Maybe, you can create a table showing the measures used inside the formatting measure. Be aware that this value (formatted by the UI) 55.0% does not equal the value 0.5501.
You need to format (adjust) the measure inside the DAX statement regarding the precision.
Hopefully, this provides some ideas on how to tackle your challenge.
Regards,
Tom
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
Check out the November 2025 Power BI update to learn about new features.
| User | Count |
|---|---|
| 59 | |
| 43 | |
| 42 | |
| 23 | |
| 17 |
| User | Count |
|---|---|
| 190 | |
| 122 | |
| 96 | |
| 66 | |
| 47 |