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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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

 

v-shex-msft
Community Support
Community Support

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

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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