---
schema_version: "1"
id: c5d4a964b9d594edfd075b7dbf291d3f36f75cac66e2ac9e06179e2b55d0b089
title: Iif()
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/marketing-cloud/ampscript/references/utilities/mc-ampscript-reference-utilities-iif.md
canonical_url: https://developer.salesforce.com/docs/marketing/marketing-cloud-ampscript/references/mc-ampscript-utilities/mc-ampscript-reference-utilities-iif.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 3aeef3e452da7ed8f77abc11d327e1150c38f239a62967812b520de1809da5c1
products:
  - AMPscript for Marketing Cloud
  - Marketing Cloud
---
# 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

<table>
  <tr>
    <td>Marketing Cloud Engagement</td>
    <td>✅ Yes</td>
  </tr>
  <tr>
    <td>Marketing Cloud Next</td>
    <td>✅ Yes</td>
  </tr>
</table>

This function became available in Marketing Cloud Next during the Summer ’26 release (API version 67.0).

## Syntax

```
Iif(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()](https://developer.salesforce.com/docs/marketing/marketing-cloud-ampscript/references/string/mc-ampscript-reference-string-concat.md) functions. It looks at the `FirstName` field from the subscriber profile for the recipient.

```
%%[
  Var @salutation, @name
  Set @name = firstname
  Set @salutation = Iif(Empty(@name), "Valued subscriber,", Concat("Dear ", @name, ","))
]%%

<p>%%=v(@salutation)=%%</p>
```

If the `FirstName` field contains a value, the `Iif()` function outputs a string that greets the subscriber by name.

```
Dear Tomás,
```

If the `FirstName` field is empty, the `Iif()` function produces a generic text string.

```
Valued subscriber,
```
