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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Taz2604
New Member

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, @Taz2604 

 

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
Taz2604
New Member

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, @Taz2604 

 

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

@Taz2604 , 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/...

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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