Forum Discussion

neskowin's avatar
neskowin
Frequent Visitor
3 years ago
Solved

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

  • Anonymous's avatar
    Anonymous
    3 years ago

    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

  • Anonymous's avatar
    Anonymous
    Not applicable

    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. 

    • neskowin's avatar
      neskowin
      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.

  • neskowin's avatar
    neskowin
    Frequent Visitor

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