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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
klehar
Helper V
Helper V

Color Code matrix based on average value of Geos

Hi,

 

I want to color code the measures data such that if a cell value > Average than show Green

if it is less than Average than show as Red

 

Data :

GeoKPIValues
North America% completition90
India% completition78
Japan% completition82
China% completition56
Europe% completition89
North America% TAT40
India% TAT78
Japan% TAT92
China% TAT94
Europe% TAT86

 

My desired output : 

klehar_0-1715588762733.png

 

I was referring to another community post

https://community.fabric.microsoft.com/t5/Desktop/Conditional-formatting-of-Matrix-based-on-Total-av...

but that doesnt seem to work, neither did that DAX make sense.

My request to the one who replies : Please explain the DAX as well

 

1 ACCEPTED SOLUTION
_AAndrade
Super User
Super User

Hi @klehar,


Here is my solution:
My table:

_AAndrade_0-1715592725635.png

I added the "Order" column to sort the Geo as you have in your desired output.
In this table the Geo column is sorted by the olumn Order as you can see here:

_AAndrade_1-1715592906354.png

Measures I used:

Value Each Geo = MIN(T_DataGeo[Values])  -- To return each value that I have in the table. You need to adjust this measure according to your needs

Avg KPY = 
CALCULATE(
    AVERAGE(T_DataGeo[Values]),
    ALLSELECTED(T_DataGeo[Geo], T_DataGeo[Order])
)
-- This measure returns the avegage to each KPY 

Color Measure = 
IF(
    [Value Each Geo] >= [Avg KPY],
    "GREEN",
    "RED"
)
-- Return the colour according to the rules you mentioned


On the Cell elements apply a Background color for the measure "Value Each Geo":

_AAndrade_2-1715593180505.png_AAndrade_3-1715593190946.png


Final Output:

_AAndrade_4-1715593217439.png

 





Did I answer your question? Mark my post as a solution! Kudos are welcome.

Proud to be a Super User!




View solution in original post

8 REPLIES 8
_AAndrade
Super User
Super User

Hi @klehar,


Here is my solution:
My table:

_AAndrade_0-1715592725635.png

I added the "Order" column to sort the Geo as you have in your desired output.
In this table the Geo column is sorted by the olumn Order as you can see here:

_AAndrade_1-1715592906354.png

Measures I used:

Value Each Geo = MIN(T_DataGeo[Values])  -- To return each value that I have in the table. You need to adjust this measure according to your needs

Avg KPY = 
CALCULATE(
    AVERAGE(T_DataGeo[Values]),
    ALLSELECTED(T_DataGeo[Geo], T_DataGeo[Order])
)
-- This measure returns the avegage to each KPY 

Color Measure = 
IF(
    [Value Each Geo] >= [Avg KPY],
    "GREEN",
    "RED"
)
-- Return the colour according to the rules you mentioned


On the Cell elements apply a Background color for the measure "Value Each Geo":

_AAndrade_2-1715593180505.png_AAndrade_3-1715593190946.png


Final Output:

_AAndrade_4-1715593217439.png

 





Did I answer your question? Mark my post as a solution! Kudos are welcome.

Proud to be a Super User!




@_AAndrade Can this be also done when my column "KPI" is actually a measure and not a column

In my real data % completion looks like this : 
% completition = 
VAR numerator = calculate(...)

VAR denominator = calculate(...)

RETURN divide(numerator, denominator, 0)

Hi,

Yes it's possible to do it, by using that measure instead of my "Valeu each Geo" measure and computes the avg measure to compare one against other.
For the new AVG measure probably you will need to use summarize function, but it depends on your model.  





Did I answer your question? Mark my post as a solution! Kudos are welcome.

Proud to be a Super User!




@_AAndrade can this also be done when the second column I mentioned (called KPI) is actually a measure and not a column? So you cant see it the way I show it in the table above

@_AAndrade cna you please attach the pbix as well

@klehar,
I'm attaching the pbix file.





Did I answer your question? Mark my post as a solution! Kudos are welcome.

Proud to be a Super User!




@_AAndrade what was the reason to create the Geo order column?

As I said before I added this column to order Geo Country like you have in your tables.

Starts from North America to Europe otherwise we will have the standard alphabetic sort.

You can ignore them if you don't need that particular sort





Did I answer your question? Mark my post as a solution! Kudos are welcome.

Proud to be a Super User!




Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.