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
ngoswami
New Member

How do i change card data value color in range by DAX measure?

I need to change the card data value color dynamically by a measure that I can use in the fx of that card! 

 

I have tried as below but it always shows green color; (colors need to be changed in range as below)  GREEN-RED-BLACK

Screenshot 2022-07-01 235422.pngScreenshot 2022-07-01 235513.png

 

 

 

 

 

 

 

Also would like to add this if condition with above as well:

IF(ISFILTERED('Variance Visibility'[SelectShowHide]),"","#FFFFFF")
 
If someone can help it would be great! 
Thanks in advance!!!
1 ACCEPTED SOLUTION
v-yanjiang-msft
Community Support
Community Support

Hi @ngoswami ,

In your measure, Any value will satisfy the first two conditions, greater than 0 or less than 0.01, so it always returns green. If your desired result is :

0<Value<0.01 then green;

-0.01<Value<0 then red;

Value=0 then black.

Then here's my solution.

Measure =
IF (
    'Variance Selection'[Lead Variance %] > 0
        && 'Variance Selection'[Lead Variance %] < 0.01,
    "#2DD224",
    IF (
        'Variance Selection'[Lead Variance %] > -0.01
            && 'Variance Selection'[Lead Variance %] < 0,
        "#D64550",
        IF ( 'Variance Selection'[Lead Variance %] = 0, "#000000" )
    )
)

 Get the correct result.

vkalyjmsft_0-1657192936153.png

vkalyjmsft_1-1657192959394.png

vkalyjmsft_2-1657192977364.png

I attach my sample below for reference.

 

Best Regards,
Community Support Team _ kalyj

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

 

View solution in original post

2 REPLIES 2
v-yanjiang-msft
Community Support
Community Support

Hi @ngoswami ,

In your measure, Any value will satisfy the first two conditions, greater than 0 or less than 0.01, so it always returns green. If your desired result is :

0<Value<0.01 then green;

-0.01<Value<0 then red;

Value=0 then black.

Then here's my solution.

Measure =
IF (
    'Variance Selection'[Lead Variance %] > 0
        && 'Variance Selection'[Lead Variance %] < 0.01,
    "#2DD224",
    IF (
        'Variance Selection'[Lead Variance %] > -0.01
            && 'Variance Selection'[Lead Variance %] < 0,
        "#D64550",
        IF ( 'Variance Selection'[Lead Variance %] = 0, "#000000" )
    )
)

 Get the correct result.

vkalyjmsft_0-1657192936153.png

vkalyjmsft_1-1657192959394.png

vkalyjmsft_2-1657192977364.png

I attach my sample below for reference.

 

Best Regards,
Community Support Team _ kalyj

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

 

daXtreme
Solution Sage
Solution Sage

The condition is wrong. Instead of IF, please use SWITCH (https://dax.guide/switch) and remember that the conditions are evaluated in the sequence you define.

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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