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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Changing Text Colours Based On Value

Hi, 

 

I have a data set which contains various columns that have "Yes" or "No" values. I have these columns displayed in a table and want the values to change colour.

 

If the value is "Yes" I want the text colour to change to Red

If the value is "No" I want the text colour to remain black

 

After browsing around on forums I have found the below Dax and have added it to the conditional format of each column but it is not working. Any ideas on how to achieve this?

 

Colour Change =
VAR Dept = SELECTEDVALUE('Safety Valve'[B A])
RETURN IF(Dept <> BLANK(), "Red", "Black")
 

Many thanks,

 

E

1 ACCEPTED SOLUTION
Pragati11
Super User
Super User

Hi @Anonymous ,

 

Your Dax expression doesn't look right. For RED or GREEN color you will have to use HEX COLOR CODES. This is what Power BI understands as colours.

 

Try creating a measure using following dax:

Colour Change =
VAR Dept = SELECTEDVALUE('Safety Valve'[B A])
RETURN 
SWITCH( TRUE(),
Dept = "Yes", "#FF0000",
Dept = "No", "#008000"
)
 
You this measure as an conditional formatting in your table visual on your column which has got values YES/NO. 
You can change the hex color codes as per your requirement.
 
Thanks,
Pragati
 

Best Regards,

Pragati Jain


MVP logo


LinkedIn | Twitter | Blog YouTube 

Did I answer your question? Mark my post as a solution! This will help others on the forum!

Appreciate your Kudos!!

Proud to be a Super User!!

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@Anonymous , use the measure you created in conditional formatting with "Field" option

 

https://radacad.com/dax-and-conditional-formatting-better-together-find-the-biggest-and-smallest-numbers-in-the-column
https://docs.microsoft.com/en-us/power-bi/desktop-conditional-table-formatting#color-by-color-values

 

example measures

Color sales = if(AVERAGE(Sales[Sales Amount])<170,"green","red")
Color Year = if(FIRSTNONBLANK(Table[Year],2014) <=2016,"lightgreen",if(FIRSTNONBLANK(Table[Year],2014)>2018,"red","yellow"))

 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Pragati11
Super User
Super User

Hi @Anonymous ,

 

Your Dax expression doesn't look right. For RED or GREEN color you will have to use HEX COLOR CODES. This is what Power BI understands as colours.

 

Try creating a measure using following dax:

Colour Change =
VAR Dept = SELECTEDVALUE('Safety Valve'[B A])
RETURN 
SWITCH( TRUE(),
Dept = "Yes", "#FF0000",
Dept = "No", "#008000"
)
 
You this measure as an conditional formatting in your table visual on your column which has got values YES/NO. 
You can change the hex color codes as per your requirement.
 
Thanks,
Pragati
 

Best Regards,

Pragati Jain


MVP logo


LinkedIn | Twitter | Blog YouTube 

Did I answer your question? Mark my post as a solution! This will help others on the forum!

Appreciate your Kudos!!

Proud to be a Super User!!

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.