Compare Dates and Show font in red based on result

Hi,

I wanted to compare two dates and show font in red when the result is true.
Here’s what I am trying to achieve.
Can some help me understand where i am going wrong

image

[Measures].[Issue Date IRL 2 Entry]
CASE WHEN DateCompare(
[Measures].[Actual IRL1 Exit Date] > [Measures].[Target IRL1 Exit Date])
THEN
“<span style='color:red>”
END

Hi @Tanu,

You are on the right track. There are a few adjustments to make this work.

  1. Use function DateCompare() to compare two dates. There are more details and example of this function: DateCompare

  2. Date that you would like to show in the red color should be between <span ...> and </span>.

  3. Make sure to set measure formatting to Markdown (Calculated measures and members)

The updated formula might look like this:

CASE WHEN --compare two dates
  DateCompare(
    [Measures].[Actual IRL1 Exit Date],
    [Measures].[Target IRL1 Exit Date]
  ) > 0
THEN --if Actual date > Target date
  "<span style='color:red'>" || 
  Format([Measures].[Issue Date IRL 2 Entry],'dd mmm yyyy')
  || "</span>" 
END

Check out tips and tricks on measure formatting for more examples:

Best,
Zane support@eazyBI.com