Forum Discussion
Color formatting when text in two different columns are different.
- 1 year ago
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 - 1 year ago
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 colorsNote: 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).
- 1 year ago
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:
- Select your Initial Ruling or Final Ruling column
- Format → Conditional formatting → Background color
- Format by: Field value (use your new calculated column)
- 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.
When I do:
If I try the other way I get an error:
Thoughts?