Verification in progress Differs from official docs Test scripts included

Keeps only the list items that pass a field/operator/value test.

Syntax

{{filter list fieldName comparisonOperator targetValue filterAs}}

Returns array.

Parameters

Name Type Required Description
list array Yes List of objects to check.
fieldName string Yes Name of the field to compare.
comparisonOperator string Yes Comparison operator (e.g. >, ==, CONTAINS).
targetValue any Yes Value the field is compared with.
filterAs string Yes The type to filter as: string, number, or date.

Example

Tested in a Marketing Cloud Next email on 2026-11-25, alone in the email, with a list of objects built in AMPscript (Handlebars reads it as variable rows):

  • %%[ SET @rows = BuildRowsetFromJSON('[{"name":"Bob","age":27},{"name":"Ann","age":21},{"name":"Cid","age":24}]', '$[*]', 1) ]%%{{#each (filter rows "age" ">" 22 "number")}}[{{name}}]{{/each}} fails the email preview with HTTP 500. The documented result is [Bob][Cid]. The same rows render with each and with sort.
  • {{#each (filter (jsonpath '[{"name":"Bob","age":27},{"name":"Ann","age":21}]' "$") "age" ">" 22 "number")}}[{{name}}]{{/each}} also fails the preview with HTTP 500, as do a string comparison ("name" "==" "Ann" "string") and the documented chain map (filter …) "name". The same jsonpath list renders with each.
  • {{#if false}}{{filter myList "age" ">" 25 "number"}}{{/if}} is accepted when the email is saved.
Show Next test script
<!-- Marketing Cloud Next test script for the filter helper. Paste it into the HTML component of a
     Next email and open the preview. Each line prints the result Next gave when the call
     was rendered on its own (expect) next to the result of this run (got).
     Assembled from single-call test emails (dates on the page); it has not been
     run as one email. Calls that make Next fail are listed separately. -->
<p>c1 expect=[gated] got=[{{#if false}}{{filter probeList "age" ">" 25 "number"}}{{/if}}gated]</p>

Show calls that fail in Next (one email each)
<!-- Run each call below in its own Next email: one of them in a combined email
     would stop the whole preview or block the save. -->

<!-- email 1: expect that the email saves, but the preview fails (HTTP 500) -->
%%[ SET @rows = BuildRowsetFromJSON('[{"name":"Bob","age":27},{"name":"Ann","age":21},{"name":"Cid","age":24}]', '$[*]', 1) ]%%{{#each (filter rows "age" ">" 22 "number")}}[{{name}}]{{/each}}

<!-- email 2: expect that the email saves, but the preview fails (HTTP 500) -->
{{#each (filter (jsonpath '[{"name":"Bob","age":27},{"name":"Ann","age":21}]' "$") "age" ">" 22 "number")}}[{{name}}]{{/each}}

<!-- email 3: expect that the email saves, but the preview fails (HTTP 500) -->
{{map (filter (jsonpath '[{"name":"Bob","age":27},{"name":"Ann","age":21}]' "$") "age" ">" 22 "number") "name"}}

<!-- email 4: expect that the email saves, but the preview fails (HTTP 500) -->
{{#each (filter (jsonpath '[{"name":"Bob"},{"name":"Ann"}]' "$") "name" "==" "Ann" "string")}}[{{name}}]{{/each}}

Differs from official docs

  • The reference shows {{filter myList "age" ">" 25 "number"}} returning the matching objects. In Marketing Cloud Next (tested 2026-11-25): the same call form on a list of objects built with AMPscript BuildRowsetFromJSON failed the email preview with HTTP 500, although each and sort read that list. Lists built with jsonpath fail the same way. Details

Marketing Cloud Next

See also