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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Anonymous
Not applicable

Colour coding cells based on value

Hi Guys,

 

I have multiple columns which need to be colour coded based on the text present in them. For example, if the letter "G" is present in cells, I need the cell to be "Green"; "A" is "Amber" and so on.

I have 6 letters corresponding to colours like these spread over 9 columns. How do I do this? I need to visualise this in a "Table" 

 

 

Issues.JPG

Capture_co.JPG

 

Please help. I have attached a screenshot of it.

1 ACCEPTED SOLUTION
v-zhangti
Community Support
Community Support

Hi, @Anonymous 

 

You can try the following method to write a measure about the color for each column. This is shown below.

Measure1 = Switch(True(),
SELECTEDVALUE('Table'[BCP])="G","Green",
SELECTEDVALUE('Table'[BCP])="A","Amber",
SELECTEDVALUE('Table'[BCP])="N","Red",
SELECTEDVALUE('Table'[BCP])="W","White")
Measure2 = Switch(True(),
SELECTEDVALUE('Table'[DR])="G","Green",
SELECTEDVALUE('Table'[DR])="A","Yellow",
SELECTEDVALUE('Table'[DR])="N","Red",
SELECTEDVALUE('Table'[DR])="W","White")
Measure3 = Switch(True(),
SELECTEDVALUE('Table'[IWsuraWce])="G","Green",
SELECTEDVALUE('Table'[IWsuraWce])="A","Yellow",
SELECTEDVALUE('Table'[IWsuraWce])="N","Red",
SELECTEDVALUE('Table'[IWsuraWce])="W","White")

Then add conditional formatting to each column.

vzhangti_0-1657019940482.png vzhangti_1-1657019953672.png

Does this resemble the output you expect?

vzhangti_2-1657019994385.png

 

Best Regards,

Community Support Team _Charlotte

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Thanks a ton all!

 

I ended up using the Switch formula with multiple columns and assigning a numerical value to each colour I wanted to use.

v-zhangti
Community Support
Community Support

Hi, @Anonymous 

 

You can try the following method to write a measure about the color for each column. This is shown below.

Measure1 = Switch(True(),
SELECTEDVALUE('Table'[BCP])="G","Green",
SELECTEDVALUE('Table'[BCP])="A","Amber",
SELECTEDVALUE('Table'[BCP])="N","Red",
SELECTEDVALUE('Table'[BCP])="W","White")
Measure2 = Switch(True(),
SELECTEDVALUE('Table'[DR])="G","Green",
SELECTEDVALUE('Table'[DR])="A","Yellow",
SELECTEDVALUE('Table'[DR])="N","Red",
SELECTEDVALUE('Table'[DR])="W","White")
Measure3 = Switch(True(),
SELECTEDVALUE('Table'[IWsuraWce])="G","Green",
SELECTEDVALUE('Table'[IWsuraWce])="A","Yellow",
SELECTEDVALUE('Table'[IWsuraWce])="N","Red",
SELECTEDVALUE('Table'[IWsuraWce])="W","White")

Then add conditional formatting to each column.

vzhangti_0-1657019940482.png vzhangti_1-1657019953672.png

Does this resemble the output you expect?

vzhangti_2-1657019994385.png

 

Best Regards,

Community Support Team _Charlotte

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

amitchandak
Super User
Super User

@Anonymous , You can not do conditional formatting for the column header. But you do for data cells

 

You can create  a color measure and use that in conditional formatting using the field value option

 

example

Measure =
Switch(true(),
max(Table[Column]) = "R1" , "Red" ,
max(Table[Column]) = "R2" , "Green" ,
max(Table[Column]) = "R3" , "Pink "
)

 

How to do conditional formatting by measure and apply it on pie?
https://www.youtube.com/watch?v=RqBb5eBf_I4&list=PLPaNVDMhUXGYo50Ajmr4SgSV9HIQLxc8L
https://community.powerbi.com/t5/Community-Blog/Power-BI-Conditional-formatting-the-Pie-Visual/ba-p/1682539

Helpful resources

Announcements
PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.