Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago
Solved

Need help with conditional formatting

Hi all,

So I have this table and I want to highlight the first 'def' value because it's different from the one right above. Then I want to highlight the first 'ghi' for the same reason. Is this possible some way in Power BI?

The different values just need to stand out.

 

Thanks.

  • Hi Anonymous ,

     

    One sample for your reference. Please check the following steps as below.

     

    1. Insert an index column in power query.

     

    2. To create a measure as below and set conditional formatting based on the measure.

     

    Measure =
    VAR ind =
        MAX ( Table1[Index] ) + 1
    VAR cal =
        CALCULATE (
            MAX ( Table1[name] ),
            FILTER ( ALL ( Table1 ), Table1[Index] = ind )
        )
    RETURN
        IF ( MAX ( Table1[name] ) = cal && ind <> 2, "#01B8AA", "#000000" )
    

    Pbix as attached.

     

5 Replies

    • Anonymous's avatar
      Anonymous
      Not applicable

      parry2k 

      I need to do this for each column. or each row. whatever works.

      I need 'def' to be highlighted because it was 'abc' in the row right above it, and then I also need '2' to be highlighted as it was '1' in the row right above it.

      So if this formatting is applied row-wise, meaning rowsare compared to each other and different values are highlighted, then that is good enough for me too.

  • v-frfei-msft's avatar
    v-frfei-msft
    Community Support

    Hi Anonymous ,

     

    One sample for your reference. Please check the following steps as below.

     

    1. Insert an index column in power query.

     

    2. To create a measure as below and set conditional formatting based on the measure.

     

    Measure =
    VAR ind =
        MAX ( Table1[Index] ) + 1
    VAR cal =
        CALCULATE (
            MAX ( Table1[name] ),
            FILTER ( ALL ( Table1 ), Table1[Index] = ind )
        )
    RETURN
        IF ( MAX ( Table1[name] ) = cal && ind <> 2, "#01B8AA", "#000000" )
    

    Pbix as attached.

     

    • Anonymous's avatar
      Anonymous
      Not applicable

      v-frfei-msft 

      Thank you for your help.

      However, I get this result when I apply your code. Can you help me modify it so that only the first "def" is highlighted, and not the rest?

      Keeping in mind that if my data looked like this:

      abc

      def *

      def

      ghi *

      def *

      ghi *

       

      Then I will need all the ones with the * highlighted as they are different from the one above them.

       

    • Anonymous's avatar
      Anonymous
      Not applicable

      v-frfei-msft 

       

      If the value of "name" at index 2 is different from the value of "name"at index 1, then change color of "name" at index 2,
      If the value of "name" at index 3 is different from the value of "name"at index 2, then change color of "name" at index 3,
      If the value of "name" at index 4 is different from the value of "name"at index 3, then change color of "name" at index 4.

       

      This will be the simple logic. But I don't know how to write it in PBI, Measures language.So if you can help with that, that'd be great.