Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago
Solved

Conditional formatting on table based on cell value till the cell

Hello to all

 

I don't know if this is possible and i'm not beeing able to do it.

 

Consider the following table:

Name    Value

cell1      10

cell2      15

cell3      0

cell4      20

cell5      5

cell6      8

cell7      7

 

MeasureA with value 35.

 

What I would like to do is something like this:

cell1 Value is less that MeasureA, yes.. color it green

cell1 Value + cell2 Value is less that MeasureA, yes color it green

cell1 Value + cell2 Value + cell3 Value is less that MeasureA, yes color it green

cell1 Value + cell2 Value + cell3 Value + cell4 Value is less that MeasureA, no don't color it..

 

Is this achievable?

 

Thanks

  •  Hi Anonymous

     

    You may try to add some measure and then use conditional formatting on the table.

    MeasureB =
    CALCULATE (
        SUM ( Table4[Value] ),
        FILTER ( ALL ( Table4 ), Table4[Name ] <= MAX ( Table4[Name ] ) )
    )
    MeasureC =
    IF ( [MeasureB] < [MeasureA], 1 )

     

    Regards,

    Cherie

     

8 Replies

  • v-cherch-msft's avatar
    v-cherch-msft
    Microsoft Employee

     Hi Anonymous

     

    You may try to add some measure and then use conditional formatting on the table.

    MeasureB =
    CALCULATE (
        SUM ( Table4[Value] ),
        FILTER ( ALL ( Table4 ), Table4[Name ] <= MAX ( Table4[Name ] ) )
    )
    MeasureC =
    IF ( [MeasureB] < [MeasureA], 1 )

     

    Regards,

    Cherie

     

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hello v-cherch-msft

       

      Thanks for the quick reply. 

       

      It is almost working.. :)

       

      It gives me a intial value (in my case 15) which in fact should be 0. It might be due to filters I have. I tried whitout the all but the result is the same.

       

      How can I overcome this?

       

      Regards

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hello again v-cherch-msft

       

      In fact what I have is:

      ID    Order    Value

      3         3          10

      4         6          4

      2         7          0

      1         9          6

      5         10        0

      8         11        0

      6         15        3

      7         16        7

       

      With this measure as you suggest:

      MeasureB =
      CALCULATE (
      SUM ( Table4[Value] );
      FILTER ( ALL( Table4 ) ; Table4[Order] <= MAX ( Table4[Order] ) )
      )

       

      but if i add the measure to the table I get incorrect values. If I remove ALL it is even worse because it does not add as expected.

      • v-cherch-msft's avatar
        v-cherch-msft
        Microsoft Employee

        Hi Anonymous

         

        It seems nothing wrong with your measure. You need drag the order column and value column in table visual.

         

        Regards,

        Cherie

    • Anonymous's avatar
      Anonymous
      Not applicable

      Thanks v-cherch-msft

       

      After using the allexcept in the correct column all worked.

       

      Thanks