# ExecuteFilter()

Executes a data filter and returns an unordered rowset that contains the results.

This function only works with data filters that are based on data extensions. You can’t use this function with data filters that are based on profile attributes.

Use this function only on CloudPages, landing pages, microsites, and SMS messages created in MobileConnect.

## Availability

<table>
  <tr>
    <td>Marketing Cloud Engagement</td>
    <td>✅ Yes</td>
  </tr>
  <tr>
    <td>Marketing Cloud Next</td>
    <td>❌ No</td>
  </tr>
</table>

## Syntax

```
ExecuteFilter(dataFilterExternalId)
```

The `ExecuteFilter()` function has one parameter:

- `dataFilterExternalId` (string): Required. The external ID of the data filter to execute. This function only works with data filters that are based on data extensions.

## Usage

This example uses a data extension called "MembershipRewardsProgramme," which contains the data in this table.

| MemberId | FirstName | Surname    | RewardsPoints | RewardsTier | Area        |
| -------- | --------- | ---------- | ------------- | ----------- | ----------- |
| 1        | Dennis    | Smithers   | 92374         | 2           | Chelsea     |
| 2        | Pooja     | Chatterjee | 201042        | 1           | Hammersmith |
| 3        | Tomás     | Santos     | 69311         | 3           | Kensington  |
| 4        | Sun-Hi    | Kim        | 23999         | 4           | Twickenham  |
| 5        | Jian      | Yeh        | 15123         | 4           | Chelsea     |

The account also contains a data filter called "MembershipRewardsProgramme\_50k points plus," with an external key of `c5a7e0d9-41e0-4068-bdcc-8766d7c1af94`. This data filter searches for all values in which the number in the RewardsPoints column is greater than or equal to 50000.

This code example filters the data extension based on the data filter.

```
<table>
  <tr>
    <th>Rank</th>
    <th>MemberId</th>
    <th>FirstName</th>
    <th>Surname</th>
    <th>RewardsPoints</th>
    <th>Area</th>
  </tr>
%%[
  Var @rows, @rowCount, @filterExtId
  Set @filterExtId = "c5a7e0d9-41e0-4068-bdcc-8766d7c1af94"
  Set @rows = ExecuteFilter(@filterExtId)
  Set @rowCount = RowCount(@rows)
  If @rowCount > 0 then
    For @counter = 1 to @rowCount do
      Var @row, @rank, @memberId, @firstName, @surname, @rewardsPoints, @rewardsTier, @area
      Set @row = Row(@rows, @counter)
      Set @memberId = Field(@row, "MemberId")
      Set @firstName = Field(@row, "FirstName")
      Set @surname = Field(@row, "Surname")
      Set @rewardsPoints = Field(@row, "RewardsPoints")
      Set @area = Field(@row, "Area")
]%%
  <tr>
    <td>%%=v(@counter)=%%</td>
    <td>%%=v(@memberId)=%%</td>
    <td>%%=v(@firstName)=%%</td>
    <td>%%=v(@surname)=%%</td>
    <td>%%=v(@rewardsPoints)=%%</td>
    <td>%%=v(@area)=%%</td>
  </tr>
%%[
      Next @counter
  EndIf
]%%
</table>
```

The code example returns a table that contains values from the rowset.

| Rank | MemberId | FirstName | Surname    | RewardsPoints | Area        |
| ---- | -------- | --------- | ---------- | ------------- | ----------- |
| 1    | 1        | Dennis    | Smithers   | 92374         | Chelsea     |
| 2    | 2        | Pooja     | Chatterjee | 201042        | Hammersmith |
| 3    | 3        | Tomás     | Santos     | 69311         | Kensington  |
