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

Data Days is here! Join us now for 60+ days of learning, challenges, and connection. Learn more

Reply
SaiKumar123
Regular Visitor

DAX Color coding

I have 3 fields ie., Columns
1)Goal
2)Actual
3)Better value


If the Actual is greater than the Goal and Better Value is High then the condition is True and 4th COlumn Status should be Green if condition fails then Status should be Red.

If the Actual is Less then the Goal and Better values is Low then the condition is True and 4th COlumn Status should be Green if condition fails then Status should be Red.

 

If the Actual is greater than the Goal and Better Value is Low then the condition is False and 4th COlumn Status should be Red.
If the Actual is Less than the Goal and Better value is high then the condition is False and 4th COlumn Status should be Red.

 

Goal Actuals Bettervalues Status
12.00 231.00 High G
13.00 321.00 Low R
231.00 123.00 Low G
321.00 421.00 High G
123.00 34.00 High R
321.00 34.00 Low G
34.00 153.86 Low R
34.00 157.80 High G


The code is somthing like this

if((Months_Actuals>Goal)and([Metric - better values]='Low'),red(),
if((Months_Actuals<Goal)and([Metric - better values]='High'),red(),green()))

 

how to do it in Powerbi DAX


I need to derive a Status Column newly and need to color the cell with Red and Green based on the condition

2 REPLIES 2
Anonymous
Not applicable

There is no Colour function in DAX, you have to use conditional formatting for a measure created with below formula


Status Color = IF(AND(SELECTEDVALUE('Test conditional Formating'[Actuals])>SELECTEDVALUE('Test conditional Formating'[Goal]),SELECTE
DVALUE('Test conditional Formating'[Bettervalues])="Low"),1,IF(AND(SELECTEDVALUE('Test conditional Formating'[Actuals])<SELECTEDVALUE('Test conditional Formating'[Goal]),SELECTEDVALUE('Test conditional Formating'[Bettervalues])="High"),1,0))

Now you can go to formatting pane and there conditional format for 1 background and font color both as red and same green for 0.

 

I have uploaded sample file for you reference https://github.com/sourabhkant/PowerBI

 

Anonymous
Not applicable

HI @SaiKumar123,

 

Dax not contain any color coding functions, I'd like to suggest you use conditional formatting to instead.

Conditional formatting in tables

 

Regards,

Xiaoxin Sheng

Helpful resources

Announcements
Fabric Data Days is here Carousel

Fabric Data Days 2026

Don't miss out on Data Days, June 15 through August 7. Learn Fabric, Power BI, SQL, AI and more.

May Power BI Update Carousel

Power BI Monthly Update - May 2026

Check out the May 2026 Power BI update to learn about new features.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.