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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
RajK2
Helper V
Helper V

Color code with DAX

I've creted metrix table

 

I try to do condition Font color as doesn't support me

 

VAR _value  = [Value]
RETURN IF(AND(_value<=-0.01,SELECTEDVALUE('Category'[Type]) IN {"Banana","Papaya"}<=-0.01),"Red",
              IF(AND(_value>=0.01,SELECTEDVALUE('Category'[Type]) IN {"Pomo","Orange"}>=0.01),"Red","White"))

 

IF Banana/papaya negative value then Red, if orange, pomo positve value then red.

pls advise on DAX

 

region       Banana      orange pomo  papaya

US               0.1           0.2        0.4        0.7

Denmark   0.5            0.6         0.3        -0.2

NZ            -0.6            0.3         -0.7        0.8

UK            0.5            -0.2         0.6        -0.9

9 REPLIES 9
v-pgoloju
Community Support
Community Support

Hi @RajK2 ,

I hope this information is helpful. Please let me know if you have any further questions or if you'd like to discuss this further. If this answers your question, please accept it as a solution and give it a 'Kudos' so other community members with similar problems can find a solution faster.

Thank you.

V-yubandi-msft
Community Support
Community Support

Hi @RajK2 ,

May I ask if you have resolved this issue? If so, please mark the helpful reply and accept it as the solution. This will be helpful for other community members who have similar problems to solve it faster.

Thank you.

V-yubandi-msft
Community Support
Community Support

Hi @RajK2 ,

We noticed we haven't received a response from you yet, so we wanted to follow up and ensure the solution we provided addressed your issue. If you require any further assistance or have additional questions, please let us know.

Your feedback is valuable to us, and we look forward to hearing from you soon.

 

Thanks..

V-yubandi-msft
Community Support
Community Support

Hi @RajK2 ,

Thank you for reaching out to the Microsoft Fabric community.

Could you please try the one listed below:

FontColorMeasure = 
VAR _value = [Value]
VAR _type = SELECTEDVALUE('Category'[Type])
 
RETURN 
    SWITCH(
        TRUE(),
        AND(_value <= -0.01, _type IN {"Banana", "Papaya"}), 1, 
        AND(_value >= 0.01, _type IN {"Pomo", "Orange"}), 1, 
        0 
    )

 

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

Cookistador
Super User
Super User

Hello @RajK2 
Why are you not using conditional formatting instead of dax ?

I need font color to change for requirement

rajendraongole1
Super User
Super User

Hi @RajK2  - Try this updated DAX formula 

VAR _value = [Value]
VAR _category = SELECTEDVALUE('Category'[Type])

RETURN
IF(
OR(
AND(_value < 0, _category IN {"Banana", "Papaya"}),
AND(_value > 0, _category IN {"Pomo", "Orange"})
),
"Red",
"White"
)

 

HOpe this works.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





I try to use Font color = If text = Red then color option

 

the formula not return Red or white

 

error : DAX comparison operations do not support comparing values of the text with value of the integer.consider using VALUE or Format function to convert one of the values

Hi @RajK2  can you try below one:

 

Font Color =
VAR _value = [Value]
VAR _category = SELECTEDMEASURENAME() // Gets the column name dynamically

RETURN
IF(
OR(
AND(_value < 0, _category IN {"Banana", "Papaya"}),
AND(_value > 0, _category IN {"Pomo", "Orange"})
),
"Red",
"White"
)

 

Hope this helps.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.