cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
New Member

Row value vs Average total conditional formatting

Hi All,

 

I have a simple table with value:

Col1  Col2

A       100

B       150

C       200

D      250

 

I want to highlight Col2 values which are less than the average of all the Col2 values(average is 175) as red and more than and equal to values as green. 100 and 150 will come as red and 200 and 250 will come as green. Is there a way I can acheive this?

1 ACCEPTED SOLUTION
Super User III
Super User III

Hi @Aditya-Upadhyay ,

 

Create the following measure:

Condittional formatting  = IF(SUM('Table'[Column2]) <= AVERAGEX(ALLSELECTED('Table'[Column1];'Table'[Column2]);'Table'[Column2]);"Red";"Green")

 

Then just use this column to make the condittional formatting:

MFelix_0-1599737388244.png

 

You can change the "Red" "Green" to custom colour formatting using the HEX codes like this "#ffffff"

 


Regards

Miguel Félix


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

Proud to be a Super User!

Check out my blog:

Power BI em Português





View solution in original post

3 REPLIES 3
Super User III
Super User III

Hi @Aditya-Upadhyay ,

 

Create the following measure:

Condittional formatting  = IF(SUM('Table'[Column2]) <= AVERAGEX(ALLSELECTED('Table'[Column1];'Table'[Column2]);'Table'[Column2]);"Red";"Green")

 

Then just use this column to make the condittional formatting:

MFelix_0-1599737388244.png

 

You can change the "Red" "Green" to custom colour formatting using the HEX codes like this "#ffffff"

 


Regards

Miguel Félix


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

Proud to be a Super User!

Check out my blog:

Power BI em Português





View solution in original post

Super User IV
Super User IV

@Aditya-Upadhyay - You can create a measure like:

Color Flag = 
  VAR __Average = AVERAGEX('Table',[Col2])
RETURN
  IF(MAX([Col2])<__Average,1,2)

You can use this measure in your conditional formatting rules. 1 is red, 2 is green. 


---------------------------------------

@ me in replies or I'll lose your thread!!!

I have a NEW book! 
DAX Cookbook from Packt
Over 120 DAX Recipes!




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

Proud to be a Super User!




Super User IV
Super User IV

@Aditya-Upadhyay , One of the way is to condition formatting using measure with Option "Field Value"

Create a measure like this and choose it in conditional formatting after selecting "Field Value"

Color Date = if(FIRSTNONBLANK('Date'[Date],TODAY()) <today(),"lightgreen","red")

Color Date =
var _min =minx(allselected(Date,Date[Year])
return
 Switch( true(),
 FIRSTNONBLANK('Date'[Year],year(TODAY()))-_min =0 ,"lightgreen",
  FIRSTNONBLANK('Date'[Year],year(TODAY()))-_min =0 ,"blue",
 "red")

if(FIRSTNONBLANK(Table[Value],"true")= "true","green","red")

if(FIRSTNONBLANK(date[date],blank())= tofay(),"green","red")
if(max(date[date])= tofay(),"green","red")

 

 

Refer:https://radacad.com/dax-and-conditional-formatting-better-together-find-the-biggest-and-smallest-num...
https://docs.microsoft.com/en-us/power-bi/desktop-conditional-table-formatting#color-by-color-values

 



Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
Dashboard of My Blogs !! YouTube Channel !! Connect on Linkedin

Proud to be a Super User!

Helpful resources

Announcements
secondImage

Happy New Year from Power BI

This is a must watch for a message from Power BI!

December Update

Check it Out!

Click here to read more about the December 2020 Updates!

Community Blog

Check it Out!

Click here to read the latest blog and learn more about contributing to the Power BI blog!

Get Ready for Power BI Dev Camp

Get Ready for Power BI Dev Camp

Mark your calendars and join us for our next Power BI Dev Camp!.

Top Solution Authors
Top Kudoed Authors