Forum Discussion

inglexjc's avatar
inglexjc
Post Patron
1 year ago
Solved

Color formatting when text in two different columns are different.

Need to use color to show when text in 2 separate columns are different.  Example if Initial Ruling shows "Dismissed" but Final Ruling shows "Not Decided".  But other words could be used.

 

Initial Ruling (SLH)Initial Ruling DateFinal Ruling 
Dismissed5/22/2025Dismissed
Dismissed5/6/2025Not Decided
Dismissed5/16/2025Dismissed
Dismissed6/2/2025Dismissed
Dismissed5/1/2025Dismissed
Dismissed2/12/2025Dismissed
Dismissed1/24/2025Dismissed
Dismissed5/23/2025Dismissed
Dismissed4/24/2025Not Decided
Dismissed4/17/2025Dismissed
Dismissed6/2/2025Dismissed
Dismissed5/27/2025Dismissed
Dismissed4/2/2025Dismissed
Dismissed4/2/2025Dismissed
Dismissed2/20/2025Dismissed
Dismissed6/30/2025Dismissed
Dismissed1/30/2025Dismissed
Dismissed4/30/2025Dismissed
Dismissed7/15/2025Dismissed
Dismissed6/9/2025Dismissed
Dismissed4/8/2025Dismissed
Dismissed1/2/2025Dismissed
Dismissed2/4/2025Dismissed
Dismissed5/12/2025Dismissed
Dismissed3/31/2025Dismissed
  • inglexjc You could create a calculated column like the following and base the conditional formatting on it's value:

    Column = IF( [Initial Ruling] = [Final Ruling], 1, 2 )

    In PQ:

    = if [Initial Ruling] = [Final Ruling] then 1 else 2
  • hi inglexjc , You could create a conditional formatting measure:

    Conditional Formatting Color = 
    IF (
        SELECTEDVALUE ( tbl[Initial Ruling (SLH)] )
            <> SELECTEDVALUE ( tbl[Final Ruling] ),
        "Red",
        "Yellow"
    )
    --you may use any other color Power BI can interpret but a safer method is to use RGB, RGBA or Hexadecimal colors

    Note: SELECTEDVALUE returns blank if in the current row there are more than one values for the column being referenced so ensure to use a column that will return just a single ruling value for each ruling column (like a case number, etc).

     

  • you created a column instead of a  measure. 

6 Replies

  • Greg_Deckler's avatar
    Greg_Deckler
    Community Champion

    inglexjc You could create a calculated column like the following and base the conditional formatting on it's value:

    Column = IF( [Initial Ruling] = [Final Ruling], 1, 2 )

    In PQ:

    = if [Initial Ruling] = [Final Ruling] then 1 else 2
  • hi inglexjc , You could create a conditional formatting measure:

    Conditional Formatting Color = 
    IF (
        SELECTEDVALUE ( tbl[Initial Ruling (SLH)] )
            <> SELECTEDVALUE ( tbl[Final Ruling] ),
        "Red",
        "Yellow"
    )
    --you may use any other color Power BI can interpret but a safer method is to use RGB, RGBA or Hexadecimal colors

    Note: SELECTEDVALUE returns blank if in the current row there are more than one values for the column being referenced so ensure to use a column that will return just a single ruling value for each ruling column (like a case number, etc).

     

    • inglexjc's avatar
      inglexjc
      Post Patron

      When I do this: 

      Conditional Formatting Color =
      IF (
          SELECTEDVALUE ( '4HearingsAppeals Items'[Initial Ruling (SLH) (status_color_mknhxvfd)] )
              <> SELECTEDVALUE ( '4HearingsAppeals Items'[Final Ruling (SLH) (status_color_mkp6fvmp)] ),
          "Red",
          "Blue"
      And chose it as the conditional formating:

      It's not working correctly, see about 4th line down should be RED.

      What am I doing wrong?

      • danextian's avatar
        danextian
        Super User

        you created a column instead of a  measure. 

  • Hi inglexjc ,

    Both solutions work, but I'd go with Greg_Deckler 's approach - it's simpler and more reliable.

    The calculated column method:

    RulingMatch = IF([Initial Ruling] = [Final Ruling], 1, 0)

    Then use this column for conditional formatting:

    • Value = 1 → Green (matching)
    • Value = 0 → Red (different)

    Why this is better than the measure approach: The SELECTEDVALUE measure can get tricky if your table visual has any grouping or if there are multiple rows with the same values. The calculated column approach works consistently regardless of how your visual is set up.

    Power Query version (if you prefer doing it there):

    = if [Initial Ruling] = [Final Ruling] then "Match" else "Different"

    Then color format based on "Match" vs "Different".

    For your conditional formatting:

    1. Select your Initial Ruling or Final Ruling column
    2. Format → Conditional formatting → Background color
    3. Format by: Field value (use your new calculated column)
    4. Set colors: 1 = Green, 0 = Red

    This way you get a clear visual indication whenever the rulings don't match, which seems to be what you're looking for.

    The calculated column approach is bulletproof and works in any visual configuration.


    If my response resolved your query, kindly mark it as the Accepted Solution to assist others. Additionally, I would be grateful for a 'Kudos' if you found my response helpful.
    This response was assisted by AI for translation and formatting purposes.

    • inglexjc's avatar
      inglexjc
      Post Patron

      When I do:

      RulingMatch =
      IF ( '4HearingsAppeals Items'[Initial Ruling (SLH) (status_color_mknhxvfd)] = '4HearingsAppeals Items'[Final Ruling (SLH) (status_color_mkp6fvmp)], 1, 0)
      The new column is working correctly. But the conditional formating is not working.  It doesn't give me "RulingMatch" as an option. It's grayed out:

      If I try the other way I get an error:

      Thoughts?