cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
abukapsoun
Helper V
Helper V

highlight cell value based on color

Hi 

 

I have a table as visual in powerBI. i would like to apply some colors if a cell value in a certain column equals to something.

for example if cell value = 2 then highglihgt the cell with red

if cell value = 4 highlight it with blue

 

I tried to apply the following

https://docs.microsoft.com/en-us/power-bi/create-reports/desktop-conditional-table-formatting#:~:tex....

 

But it did not work

 

I applied this formula to create a new column

Table.AddColumn(#"Unpivotted","test", each if [P08 Evaluation] ="Attention to Cost" then "#198c19" else "#a500ff")

 

Then I formatted my column based on this newly created column

 

here is the error I am getting,

abukapsoun_0-1599910900900.png

 

 

1 ACCEPTED SOLUTION
nandukrishnavs
Community Champion
Community Champion

@abukapsoun 

 

You have to create a measure and use that measure in the field format option.

 

Example:

DAX measure

Color = 
var _cellvalue= SELECTEDVALUE('Table'[LastTransaction])
var _color= IF(_cellvalue="No","#198c19","#a500ff")
return _color

nandukrishnavs_0-1599911490464.png

nandukrishnavs_1-1599911513865.png

 

 

Attaching the pbix file for your reference.

 

View solution in original post

7 REPLIES 7
amitchandak
Super User
Super User

@abukapsoun , if you have given column in a field value, It might have asked for Aggregation, Make sure it should be Min or Max



Power BI Features || Datamarts: https://youtu.be/8tskWsJTEpg || Field Parameters : https://youtu.be/lqF3Wa1FllE?t=70
Time Intelligence Decoded : https://youtu.be/aU2aKbnHuWs&t=145s
Did I answer your question? Mark my post as a solution! Appreciate your Kudos !! Proud to be a Super User! !!
Dashboard of My Blogs !! Connect on Linkedin !! Subscribe to my youtube Channel !!
Want To Learn Power BI | Beginners !! Advance Concepts !! Power BI For Tableau User !!
nandukrishnavs
Community Champion
Community Champion

@abukapsoun 

 

You have to create a measure and use that measure in the field format option.

 

Example:

DAX measure

Color = 
var _cellvalue= SELECTEDVALUE('Table'[LastTransaction])
var _color= IF(_cellvalue="No","#198c19","#a500ff")
return _color

nandukrishnavs_0-1599911490464.png

nandukrishnavs_1-1599911513865.png

 

 

Attaching the pbix file for your reference.

 

It worked like charm!! Thanks you very very very much. 

 

And last thing, is it possible to have a button or a slicer dropdown (yes & no) in the report, if yes is selected, this conditional formatting will be applied, and if no, then nothing?

 

Thanks again!

 

I was thinking if we can create a column with yes and no value. and then extend the IF formula, by saying if colum1 = no then color would be white. and if value = yes then we apply another if to evaluate which color to display. How can we do that with formula?

 

ive done it.

thanks

 

@nandukrishnavs

 

Color =
var _cellvalue = SELECTEDVALUE(Pivotted[P08 Evaluation])
var _yesno = SELECTEDVALUE(YesNo[Evaluate])
var _color = IF(_yesno="No","f00000",IF(_cellvalue="Attention to Cost","#ff0000",IF(_cellvalue="Attention to Sales","#ff0000")))
return _color
 
 
I have a dropdown slicer with the "evaluate" column. When Yes is selected the color ff000000 appears,
When I select No the same below error appears, "we found a value we dont recognize for background"
 
Thanks,
 
 

 

 

 

 

i was missing the # !!

 

Helpful resources

Announcements
August 2022 update 768x460.jpg

Check it Out!

Click here to learn more about the August 2022 updates!

August 1 episode 9_no_dates 768x460.jpg

The Power BI Community Show

Watch the playback when Priya Sathy and Charles Webb discuss Datamarts! Kelly also shares Power BI Community updates.

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Top Solution Authors
Top Kudoed Authors