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
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
Super User
Super User

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
Continued Contributor
Continued Contributor

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
Super User
Super User

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
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.