> ## Documentation Index
> Fetch the complete documentation index at: https://help.maestra.io/llms.txt
> Use this file to discover all available pages before exploring further.

# How to Filter Products by a Customer's Computed Field

Use this approach whenever you need to limit the products in a campaign to the value of a customer's [computed field](https://help.maestra.io/api-integrations/computed-fields.md), matched against a product custom field — in other words, show only products with the trait the customer prefers.

You can build product sets by favorite color, vacation destination, book genre, and so on. Here's how it works, using clothing size as the example.

## The task

A computed field tells you which size each customer buys most. You want to send them a set of new arrivals and show only products in their size.

To do that, build the campaign markup with [template engine](https://help.maestra.io/campaigns/message-template-engine/what-is-the-message-template-engine.md) parameters.

## How it works

* Your account has a computed field that works out which size (a [custom field](https://help.maestra.io/api-integrations/how-to-create-a-custom-field.md) on the product) the customer buys most often, and writes the value to their profile. For example, a customer who mostly buys size M gets `M`.
* A template engine function lets you pick, from any product segment, only the products with the right value for each customer. If a product's size matches the customer's computed value, it can show in the campaign.

## How to build the parameter

1. To reach the list of all unique products, use the base `Products` parameter.
2. Pick a product segment with the `GetBySegment()` function.
3. Filter the set by the customer's computed field with the `FilterByRecipientCustomField()` function.
4. Set extra filtering and sorting:

| Option | What it does |
| - | - |
| `AvailableForRecipient` | Products available in the recipient's area. You can also pick random products and unique products per group. |
| `Random` | Products in random order. |
| `SinglePerGroup` | Unique products per group. You can also pick random products. |
| `Take()` | No filtering or sorting. |

You can output any product field from the collection you've built.

## Markup example

Let's show each product's name, image, price, and size in the campaign:

```
New arrivals in your size

@{for item in Products.GetBySegment("NewArrivals").FilterByRecipientCustomField("BoughtSize").Take(4)}
    <a href="${item.URL}"><img src="${item.PictureUrl}"></a>
    ${item.Name}
    Size: ${item.CustomField.Size.Name}
    ${item.Price} USD
@{end for}
```

The customer gets an email with four new arrivals, all in their size.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.