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
ramyavelampati
Regular Visitor

set a background color of a field based column categories with other column in Table or Matrix

Hi, 

 

I have a table with two columns "Category" and "Defect". Category have values like coding, planning, requirement etc with corresponding defects in Defect column. I want to bulid a table with background color formatting based on each category for given values of defects. 

 

For example:

 

If table(category) = "coding" and table(defect) = <10 then green

If table(category) = "coding" and table(defect) = >10 then red

 

If table(category) = "planning" and table(defect) = <30 then green

If table(category) = "planning" and table(defect) = >30 then red

 

Please help me resolve this. 

 

Thanks

1 ACCEPTED SOLUTION
v-juanli-msft
Community Support
Community Support

Hi @ramyavelampati

First, the condition needs to be corrected. Since "=" symbol can only exsit in one condition, I assume the condition is:

If table(category) = "coding" and table(defect) = <10 then green

If table(category) = "coding" and table(defect) =    10 then red

 

If table(category) = "planning" and table(defect) = <30 then green

If table(category) = "planning" and table(defect) =    30 then red.

 

To achieve your goals, we should use conditional table formatting in Power BI.

Basically, we need to create a measure to detemine the color rule.

There are two ways.

1. create a IF condition in a measure.

Measure =
IF (
    MAX ( [category] ) = "coding"
        && MAX ( [defect] ) <= 10,
    1,
    IF ( MAX ( [category] ) = "planning" && MAX ( [defect] ) <= 3010 )
)

1.png

3.png

2.create a conditional column in Power Query and then create a simple measure.

2.png

Measure 2 = IF(MAX([defect])<=MAX([Custom]),1,0)

4.png

Then you can set conditional formatting as the first way.

 

Best Regards

Maggie

View solution in original post

4 REPLIES 4
v-juanli-msft
Community Support
Community Support

Hi @ramyavelampati

First, the condition needs to be corrected. Since "=" symbol can only exsit in one condition, I assume the condition is:

If table(category) = "coding" and table(defect) = <10 then green

If table(category) = "coding" and table(defect) =    10 then red

 

If table(category) = "planning" and table(defect) = <30 then green

If table(category) = "planning" and table(defect) =    30 then red.

 

To achieve your goals, we should use conditional table formatting in Power BI.

Basically, we need to create a measure to detemine the color rule.

There are two ways.

1. create a IF condition in a measure.

Measure =
IF (
    MAX ( [category] ) = "coding"
        && MAX ( [defect] ) <= 10,
    1,
    IF ( MAX ( [category] ) = "planning" && MAX ( [defect] ) <= 3010 )
)

1.png

3.png

2.create a conditional column in Power Query and then create a simple measure.

2.png

Measure 2 = IF(MAX([defect])<=MAX([Custom]),1,0)

4.png

Then you can set conditional formatting as the first way.

 

Best Regards

Maggie

This is dindn't work. As I have 3 different values for one category and these mesures change for other category as well. for example is 10 is green in coding, 12 will be green for planning, 20 will will be green for requirements. 

 

I already tried the meausre you mentioned, it is turning all the values into one color. 

Hi @ramyavelampati

Generally, it will work in the way i provided, perhaps you are in a different scenario.

Could you show some data or screenshot to describe your problem clearly?

Let me check it again and I will come back to tell you.

 

Best Regards

Maggie

Anonymous
Not applicable

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.