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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
Anonymous
Not applicable

Conditional Formatting Text Color in a Table

Hi

 

I have a column in a table visual which I want to color based upon the value. So the values are text and there are only three uniqe possiblities and i want to give each option a Green, Red or a Gray color.

 

I already checked the conditional formatting option but that is around a numeric value but not text. 

 

Any clues as to how to do it efficiently?

 

Thanks

1 ACCEPTED SOLUTION
jdbuchanan71
Super User
Super User

@Anonymous 

You need to write a measure to read the value of the cell then return the name of the color.

 

Formatting = 
VAR _Value = SELECTEDVALUE ( 'Table'[Value] )
RETURN
SWITCH (
    _Value,
    "West","Green",
    "Central","Gray",
    "East","Red"
)

 

You would change West, Central, East to match your values.

Then you apply conditional formatting to the column > font color based on the Field value of the [Formatting] measure.

jdbuchanan71_0-1593465873652.png

I attached a sample file for you to take a look at.

View solution in original post

2 REPLIES 2
nandic
Resident Rockstar
Resident Rockstar

Hi,
My approach is this: go to dimension where you have a field based on which you would like to set background color.
Add new column which sets color based on specific criteria (or add that column in source).
Example:
Text background color column.PNG


Then select table and add conditional formatting to desired field:
Text background color column steps 1.PNG


Define logic:
Text background color column steps 2.PNG
And this is final result:
Text background color column final result.PNG

Cheers,
Nemanja

 

jdbuchanan71
Super User
Super User

@Anonymous 

You need to write a measure to read the value of the cell then return the name of the color.

 

Formatting = 
VAR _Value = SELECTEDVALUE ( 'Table'[Value] )
RETURN
SWITCH (
    _Value,
    "West","Green",
    "Central","Gray",
    "East","Red"
)

 

You would change West, Central, East to match your values.

Then you apply conditional formatting to the column > font color based on the Field value of the [Formatting] measure.

jdbuchanan71_0-1593465873652.png

I attached a sample file for you to take a look at.

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

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.