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

Next up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now

Reply
Anonymous
Not applicable

change back ground color of matrix based on field value

hiiii all ......im new to power bi . I am having data with error logs and site id .

i want a matrix that shows error count with differnt background color based on average error count.

 I cant change the color based on average  but the color changes with constant value.

iam sharing a sample data

 

siteid  error

1a
2ab
3abc
4a
5ab
1abc
2a
3abc
4ab
5a
  

 

my measures are  

count of error = COUNT(Table1[error])
siteidcount = DISTINCTCOUNT(Table1[siteid])
avg error count = [count of error]/[siteidcount]
 
i used this measure as field value
color change field= IF([count of error]<([avg error count]),"yellow")
i get
 
Amuthavan_94_0-1669351212246.png

 

i cant see a change in color ......but if give 

color change field = IF([count of error]<2,"yellow")
avg error count value is 2 and my color changes
Amuthavan_94_1-1669351212308.png

 

if i give 

color change field = IF([count of error]=[avg error count],"yellow") i get this
Amuthavan_94_2-1669351212311.png

 

 

need your please help..... want to change background color in value of error based on average error count

1 ACCEPTED SOLUTION
FreemanZ
Community Champion
Community Champion

try to change your measure to

 

color change field = 
VAR AvgForAll = 
CALCULATE( [avg error count], ALL())
RETURN
IF([count of error]=AvgForAll,
"yellow") 

View solution in original post

6 REPLIES 6
Anonymous
Not applicable

thanks bro ... it worked .Can u tell me what mistake i made

hi @Anonymous , You missed to add the ALL(). thats why you were not able to achieve the desired output.

 

Regards,

Nikhil Chenna

 

Appreciate with a Kudos!! (Click the Thumbs Up Button)
Did I answer your question? Mark my post as a solution!

average is the average for all, so we add ALL() to ignore the filter contexts, row and column headers in your Matrix Visual. 

Anonymous
Not applicable

when i use page filter siteid ....average count changes but the background color wont since we use All function......i want to color for the page filter as well

NikhilChenna
Skilled Sharer
Skilled Sharer

Hi @Anonymous , I think below is the solution for you.

 

I tried it myself,

1. Count of error =COUNT('Table (3)'[error])

 

2. Avg error count = CALCULATE(DIVIDE([count of error],[siteidcount]),ALL('Table (3)'))

 

This is the additional thing i added in the avg error count.

3. Count of error divided by siteidcount =

DIVIDE([Count of error], [siteidcount])
Create this measure
 
4. color change field =
IF([Count of error]<'Table (3)'[Avg error count],1,0)
 
5. Add this conditional formatting.
NikhilChenna_0-1669354473721.png

 

6. below is the output i think you need.

 

NikhilChenna_1-1669354556251.png

 

Regards,

Nikhil Chenna

 

Appreciate with a Kudos!! (Click the Thumbs Up Button)
Did I answer your question? Mark my post as a solution!

FreemanZ
Community Champion
Community Champion

try to change your measure to

 

color change field = 
VAR AvgForAll = 
CALCULATE( [avg error count], ALL())
RETURN
IF([count of error]=AvgForAll,
"yellow") 

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

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

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

FabCon and SQLCon Highlights Carousel

FabCon &SQLCon Highlights

Experience the highlights from FabCon & SQLCon, available live and on-demand starting April 14th.