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

Target Met conditional formatting

sbhan4_0-1596649715957.png

If target <=Actual then Actual value show show in Green font/ background color else Red

Thanks.

1 ACCEPTED SOLUTION
richbenmintz
Resident Rockstar
Resident Rockstar

Hi @Anonymous,

Create a Measure that returns the Hex Code you want to apply to your Back/Font Color, then use the Field Value option when setting up conditional formatting

back color = if([target]<=[actual], "#008000", "#FF0000")

Hope this helps,

 

Richard


Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up! 



I hope this helps,
Richard

Did I answer your question? Mark my post as a solution! Kudos Appreciated!

Proud to be a Super User!


View solution in original post

10 REPLIES 10
richbenmintz
Resident Rockstar
Resident Rockstar

Hi @Anonymous,

Create a Measure that returns the Hex Code you want to apply to your Back/Font Color, then use the Field Value option when setting up conditional formatting

back color = if([target]<=[actual], "#008000", "#FF0000")

Hope this helps,

 

Richard


Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up! 



I hope this helps,
Richard

Did I answer your question? Mark my post as a solution! Kudos Appreciated!

Proud to be a Super User!


Anonymous
Not applicable

@richbenmintz 

Thank you for your solution. Now I got one measure with color code. How can I use this with conditional formating so font or background of Target color should get.

Hi @Anonymous,

 

You would use the conditional value by value option

richbenmintz_0-1597180234076.png

 



I hope this helps,
Richard

Did I answer your question? Mark my post as a solution! Kudos Appreciated!

Proud to be a Super User!


Anonymous
Not applicable

 

 

 

Hi @sbhan4,

The Value needs to be a string that represents the color, like the back color measure created



I hope this helps,
Richard

Did I answer your question? Mark my post as a solution! Kudos Appreciated!

Proud to be a Super User!


Anonymous
Not applicable

@richbenmintz 

Thanks for your help!. It's not working. I have created a Black color measure. How to use that column for conditional formating.

Could you please try it in power bi workbook for me.

If Target is < Actual - red color font

if target >= Actual - Red color font

sbhan4_0-1597190119884.png

 

Hi @Anonymous,

 

Have a look at this .pbix, sample.pbix , it contains a conditional formatting measure.

 

Hope this Helps,

Richard


Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!



I hope this helps,
Richard

Did I answer your question? Mark my post as a solution! Kudos Appreciated!

Proud to be a Super User!


Anonymous
Not applicable

@richbenmintz Perfect!! It was helpful.

if(COALESCE([Val 1]<[Val 2], [Val 1]<[Val 3], [Val 1]<[Val 4])= BLANK(), "#FFFFFF", "#008000")
If i have tons of records not only 4 rows, in this case can i use if(COALESCE([Target]<=[Actual],"#FFFFFF", "#008000") now where to use BLANK

Hi @Anonymous,

 

Assuming [Target] and [Actual] are measures, you would likely use

if([target]<=[actual], "#FFFFFF", "#008000")

The Coalesce in my example was a shortcut for an 'Or' condition, essentially checking to see if any of the cases evaluated to true().

 

Richard



I hope this helps,
Richard

Did I answer your question? Mark my post as a solution! Kudos Appreciated!

Proud to be a Super User!


amitchandak
Super User
Super User

@Anonymous , create a measure that returns color based on this condition and use that in conditional formatting with "Field" Option

 

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"))

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

 

refer

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

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

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.