Calculated measure giving error

Hi,

I’m trying to create a Calculated Measure to give me the a transition date, however this transition is not always executed, so I need to implement some fallback logic via IIf clauses to use the next transition, etc.

I’ve produced the below formula, but it is giving an error when I try to save and I’m not clear why:

CASE WHEN
  1=1
THEN
    IIf(
      IsEmpty(
        ([Measures].[Transition to status first date],
          [Transition Status].[Deployed to UAT])
      )
      AND
      IsEmpty(
        ([Measures].[Transition to status first date],
          [Transition Status].[In UAT])
      ),
      ([Measures].[Transition to status first date],
        [Transition Status].[UAT Complete]),
        IIf(
          IsEmpty(
            ([Measures].[Transition to status first date],
              [Transition Status].[Deployed to UAT])
          )
        ,
        ([Measures].[Transition to status first date],
            [Transition Status].[In UAT]),
        ([Measures].[Transition to status first date],
            [Transition Status].[Deployed to UAT])
		)
	)
END

Any help would be appreciated.

Kind regards,
Freddie