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
Lolo_2023
Frequent Visitor

Background color for each values in matrix

Hi experts,

On this table, i want to add background color

For each values. If the value greater than 90

the color is grean ,and if the value between 90 and 60

The color is yellow, and if the value less than 60 the color is red .

Can anyone please help me with this?

Screenshot 2024-05-01 143448.jpeg

1 ACCEPTED SOLUTION

Measure = 
if(SELECTEDVALUE('Table'[Test])="Test1",
var _value = MAX('Table'[Values])
RETURN SWITCH(TRUE(),_value>90,"green",_value>60&&_value<=90,"yellow",_value<60,"red")
)

View solution in original post

10 REPLIES 10
Anonymous
Not applicable

Hi @Lolo_2023 ,

 

If you are presenting the same "Value" value, you can refer to the following expression:

Measure = var _value = MAX('Table'[Values])
RETURN SWITCH(TRUE(),_value>90,"green",_value>60&&_value<=90,"yellow",_value<60,"red")

 

Please feel free to correct me and provide more information if I have misunderstood you!

 

Hope it helps!

 

Best regards,
Community Support Team_ Scott Chang

 

If this post helps then please consider Accept it as the solution to help the other members find it more quickly.

Actually i want these conditions to be performed on just “Type1”

Test1.jpeg

Test2.png

then add that condition to your measure. Only return something if the SELECTEDVALUE of Type is "Type1".

Could you please provide more explanation?

Measure = 
if(SELECTEDVALUE('Table'[Test])="Test1",
var _value = MAX('Table'[Values])
RETURN SWITCH(TRUE(),_value>90,"green",_value>60&&_value<=90,"yellow",_value<60,"red")
)

 it is works perfectly, but when I am trying to change the numbers, it didn't work

Measure =

if(SELECTEDVALUE('Test'[Type])="Type1",

var _value = MAX('Test'[Values])

RETURNSWITCH(TRUE(),_value>=800&&_value<2000,"#5CB989",_value>=400&&_value<799,"#F9BA66",_value>=0&&_value<399,"#E87B72")

)
can you please check this for me

 

MEASURE =
IF (
    SELECTEDVALUE ( 'Test'[Type] ) = "Type1",
    VAR _value =
        MAX ( 'Test'[Values] )
    RETURN
        SWITCH (
            TRUE (),
            _value < 400, "#E87B72",
            _value < 800, "#F9BA66",
            _value < 2000, "#5CB989"
        )
)

 

Unfortunately, it didn't work

It works!

THANK YOU.

lbendlin
Super User
Super User

Are these independent measures or do you have a field in the column area?  

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.