Iif()

Use the Iif() function to test a condition. The first parameter contains the condition that you want to test. The condition can be any function or expression that returns true or false. If the condition is true, the function returns the second parameter. If the condition is false, it returns the third parameter.

Availability 

Marketing Cloud Engagement ✅ Yes
Marketing Cloud Next ✅ Yes

This function became available in Marketing Cloud Next during the Summer ’26 release (API version 67.0).

Syntax 

1Iif(condition, valueIfTrue, valueIfFalse)

The Iif() function has three parameters:

  • condition (string): Required. The condition to test.
  • valueIfTrue (string): Required. The value to return if the condition is true.
  • valueIfFalse (string): Required. The value to return if the condition is false.

Usage 

This example constructs a greeting for a message using the Iif() and Concat() functions. It looks at the FirstName field from the subscriber profile for the recipient.

1%%[
2  Var @salutation, @name
3  Set @name = firstname
4  Set @salutation = Iif(Empty(@name), "Valued subscriber,", Concat("Dear ", @name, ","))
5]%%
6
7<p>%%=v(@salutation)=%%</p>

If the FirstName field contains a value, the Iif() function outputs a string that greets the subscriber by name.

1Dear Tomás,

If the FirstName field is empty, the Iif() function produces a generic text string.

1Valued subscriber,