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
neskowin
Frequent Visitor

Conditional formatting one column based on a value in a matrix visual with multiple columns

I have been struggling to figure out conditional formatting in what appears to a be a complex set up. I'd appreciate any help you can extend to resolve it.

I have the following matrix visual. The rows are attributes (att1 to att7). The columns contain calculated values for two tests A and B, each done with two methods x and y. I wish to conditionally color only columns for test B, based on a composite score of test A: if (Value[B][x] > Score[A][x], "Green"); if (Value[B][x] <= Score[A][x], "Red"). Similarly for Value[B][y] and Score[A][x].

TestAABB
Methodxyxy

att1

  0.9321.094
att21.2011.2081.2011.208
att31.0411.0511.0411.051
att4  0.9690.977
att50.9490.9380.9490.938
att6  0.9281.024
att70.9220.9720.9220.972
Score1.0011.0231.0491.061

Thank you /j neskowin

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

Hi  @neskowin ,

 

According to your description, here are my steps you can follow as a solution.

(1)My test data is the same as yours.

(2) We can create two measures. 

 

measure = SUM('Table'[value])
color = var a=MAXX(FILTER(ALLSELECTED('Table'),[Test]="A"&&[attribute]="Score"&&[Method]="x"),[value])
var b=MAXX(FILTER(ALLSELECTED('Table'),[Test]="A"&&[attribute]="Score"&&[Method]="y"),[value])
return IF(OR(SELECTEDVALUE('Table'[Test])="A",SELECTEDVALUE('Table'[attribute])="Score"),"White",(IF(or(SELECTEDVALUE('Table'[Test])="B"&&SELECTEDVALUE('Table'[Method])="x"&&SUM('Table'[value])>a,SELECTEDVALUE('Table'[Test])="B"&&SELECTEDVALUE('Table'[Method])="y"&&SUM('Table'[value])>b),"green","red")))

 

(3)Set the conditional formatting as shown in the following figure and then the result is as follows.

 

 

vtangjiemsft_0-1680501880202.png

 

 

Best Regards,

Neeko Tang

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

View solution in original post

3 REPLIES 3
neskowin
Frequent Visitor

Thank you very much. I knew I had to create a measure, but couldn't figure out referencing other columns. 

v-tangjie-msft
Community Support
Community Support

Hi  @neskowin ,

 

According to your description, here are my steps you can follow as a solution.

(1)My test data is the same as yours.

(2) We can create two measures. 

 

measure = SUM('Table'[value])
color = var a=MAXX(FILTER(ALLSELECTED('Table'),[Test]="A"&&[attribute]="Score"&&[Method]="x"),[value])
var b=MAXX(FILTER(ALLSELECTED('Table'),[Test]="A"&&[attribute]="Score"&&[Method]="y"),[value])
return IF(OR(SELECTEDVALUE('Table'[Test])="A",SELECTEDVALUE('Table'[attribute])="Score"),"White",(IF(or(SELECTEDVALUE('Table'[Test])="B"&&SELECTEDVALUE('Table'[Method])="x"&&SUM('Table'[value])>a,SELECTEDVALUE('Table'[Test])="B"&&SELECTEDVALUE('Table'[Method])="y"&&SUM('Table'[value])>b),"green","red")))

 

(3)Set the conditional formatting as shown in the following figure and then the result is as follows.

 

 

vtangjiemsft_0-1680501880202.png

 

 

Best Regards,

Neeko Tang

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

Thanks. A follow-up question. The 'Table' in my project is a matrix visual created with a measure M1. In the matrix visual, the Rows are the attributes, the Columns are Tests and Methods, and the Values is the measure M1. The Score is in another matrix visual, but uses the same fields to compute the Score corresponding to the tests and methods, but using a different measure, M2. With your solution, do I now create a data table ('Table') from the matrix visuals, and if yes, is there a way to do it? If not, is there a way to refer to the matrix visual columns from your 'color' measure? Thank you.

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.