Forum Discussion

davidz106's avatar
davidz106
Icon for Helper III rankHelper III
2 years ago
Solved

Conditional formatting of Matrix cells based on previous row value

I'm working with a matrix table in Power BI containing 15 columns. I need to apply conditional formatting to highlight cells if their value differs from the value in the preceding row . I've added an...
  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi davidz106 ,

    Based on my testing, please try the following methods:

    1.Create the index column.

    2.Create the new measure to highlight the values.

    Difference = 
       VAR CurrentValue = SELECTEDVALUE('Table'[Median of Speed])
       VAR _Index = SELECTEDVALUE('Table'[Index])
       VAR PreviousValue = CALCULATE(MAX('Table'[Median of Speed]), FILTER(ALL('Table'), 'Table'[Index] = _Index - 1))
       RETURN
       IF(CurrentValue <> PreviousValue, "yellow", "white")

    3.Select the Median of Speed column and choose conditional formatting > Background color.

    4.Select Field value and choose the measure.

    5.The result is shown below.

    Best Regards,

    Wisdom Wu

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

  • davidz106's avatar
    davidz106
    2 years ago

    Got it.

     

    Difference =
    VAR CurrentValue = SELECTEDVALUE('Table'[Median of Speed])
    VAR _Index = SELECTEDVALUE('Table'[Index])
    VAR PreviousValue = CALCULATE(MAX('Table'[Median of Speed]), FILTER(ALL('Table'), 'Table'[Index] = _Index - 1))
    RETURN
    IF(
        _Index = 1,
        "white",
        IF(CurrentValue <> PreviousValue, "yellow", "white")
    )