cancel
Showing results for
Did you mean:

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

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].

 Test A A B B Method x y x y att1 0.932 1.094 att2 1.201 1.208 1.201 1.208 att3 1.041 1.051 1.041 1.051 att4 0.969 0.977 att5 0.949 0.938 0.949 0.938 att6 0.928 1.024 att7 0.922 0.972 0.922 0.972 Score 1.001 1.023 1.049 1.061

Thank you /j neskowin

1 ACCEPTED SOLUTION
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.

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.

3 REPLIES 3
Frequent Visitor

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

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.

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.

Frequent Visitor

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.

Announcements

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.