---
title: "Compound Filters"
description: "Combine Managed Investments Screener API filter conditions with and, or and not, nest them for complex logic, and use them in the scope."
url: "https://developer-beta.morningstar.com/managed-investments-screener-api/compound-filters"
image: "https://developer-beta.morningstar.com/_og/d/c_Ocean.takumi,title_~Q29tcG91bmQgRmlsdGVycyB8IE1hbmFnZWQgSW52ZXN0bWVudHMgU2NyZWVuZXIgQVBJ,description_~Q29tYmluZSBNYW5hZ2VkIEludmVzdG1lbnRzIFNjcmVlbmVyIEFQSSBmaWx0ZXIgY29uZGl0aW9ucyB3aXRoIGFuZCwgb3IgYW5kIG5vdCwgbmVzdCB0aGVtIGZvciBjb21wbGV4IGxvZ2ljLCBhbmQgdXNlIHRoZW0gaW4gdGhlIHNjb3BlLg,props_eyJ0aGVtZSI6eyJtb2RlIjoibGlnaHQiLCJjb2xvcnMiOnsicHJpbWFyeSI6IiMwMDAwMDAifX19,p_Ii9tYW5hZ2VkLWludmVzdG1lbnRzLXNjcmVlbmVyLWFwaS9jb21wb3VuZC1maWx0ZXJzIg,s_OwFWiXzwhKavBsm_.png"
---

-   [APIs](https://developer-beta.morningstar.com/apis)
-   [API Catalog](https://developer-beta.morningstar.com/api-catalog)
-   [API Assistant MCP Server](https://developer-beta.morningstar.com/api-assistant-mcp)
-   [Guides](https://developer-beta.morningstar.com/api-guides)
-   [Trial Access](https://developer-beta.morningstar.com/trial-access)

# Managed Investments Screener API

Powerful, criteria-based screening using flexible filtering logic.

# Compound Filters

[View Markdown](https://developer-beta.morningstar.com/managed-investments-screener-api/compound-filters.md)[Download Markdown](https://developer-beta.morningstar.com/managed-investments-screener-api/compound-filters.md)

Compound filters combine other filter conditions into one. Use them when a screen needs more than one condition, or when the logic is more than a simple match.

## [Compound Operators](#compound-operators)

| Operator | Meaning                            |
| :------- | :--------------------------------- |
| and      | All conditions must match.         |
| or       | At least one condition must match. |
| not      | None of the conditions can match.  |

Each operator takes an array of conditions.

```json
{
  "<operator>": [
    { "<dataPointA>": "<value>" },
    { "<dataPointB>": { "gt": "<value>" } }
  ]
}
```

Every element of the array is itself a filter condition. It can be an equality, text or comparison filter, or another compound filter.

Write the operators in lowercase.

## [Require All Conditions with And](#require-all-conditions-with-and)

The following query returns investments that have a 12-month yield in a range and a base currency of US dollars. Every condition must match.

```json
"query": {
  "and": [
    {
      "yieldsHistorical.12MoYield": { "gt": 1.5, "lt": 10.55 }
    },
    {
      "basicReference.baseCurrency": "USD"
    }
  ]
}
```

## [Require Any Condition with Or](#require-any-condition-with-or)

The following query returns investments that match the yield range, or have a base currency of US dollars, or both.

```json
"query": {
  "or": [
    {
      "yieldsHistorical.12MoYield": { "gt": 1.5, "lt": 10.55 }
    },
    {
      "basicReference.baseCurrency": "USD"
    }
  ]
}
```

## [Exclude Conditions with Not](#exclude-conditions-with-not)

The `not` operator excludes investments that match its conditions. The following query returns investments whose 12-month yield isn't in the range and whose base currency isn't US dollars.

```json
"query": {
  "not": [
    {
      "yieldsHistorical.12MoYield": { "gt": 1.5, "lt": 10.55 }
    },
    {
      "basicReference.baseCurrency": "USD"
    }
  ]
}
```

## [Nest Compound Filters](#nest-compound-filters)

Compound filters can be nested to any level you need, so you can build complex logic. The following query returns investments that have either a recent portfolio date and a low risk score, or a high Morningstar Rating.

```json
"query": {
  "or": [
    {
      "and": [
        {
          "basicReference.portfolioDate": { "gt": "2010-01-01", "lt": "2024-03-31" }
        },
        {
          "morningstarPortfolioRiskScore.portfolioRiskScore": { "lte": 25.555 }
        }
      ]
    },
    {
      "morningstarRatingHistorical.morningstarRatingOverall": { "gte": 4 }
    }
  ]
}
```

To read a nested filter, start at the outermost operator and work inward. Here, an investment is returned if it satisfies the inner `and` group, which needs both conditions, or if it satisfies the rating condition.

The following query combines `and` and `or` the other way round. It returns investments in one of two base currencies that also have a high rating and an inception date after a given day.

```json
"query": {
  "and": [
    {
      "or": [
        { "basicReference.baseCurrency": "USD" },
        { "basicReference.baseCurrency": "CAD" }
      ]
    },
    {
      "morningstarRatingHistorical.morningstarRatingOverall": { "gte": 4 }
    },
    {
      "basicReference.inceptionDate": { "gt": "2010-01-01" }
    }
  ]
}
```

## [Use Compound Filters in the Scope](#use-compound-filters-in-the-scope)

The `scope` uses the same syntax as the `query`, so it can also be a compound filter. When it is, each branch must contain the scoping data point, which for managed investments is `basicReference.countryAvailableForSale`.

The following scope covers two countries, with a different condition on each.

```json
"scope": {
  "or": [
    {
      "and": [
        { "basicReference.countryAvailableForSale": "USA" },
        { "basicReference.baseCurrency": "USD" }
      ]
    },
    {
      "and": [
        { "basicReference.countryAvailableForSale": "GBR" },
        { "basicReference.baseCurrency": "GBP" }
      ]
    }
  ]
}
```

A branch without the scoping data point isn't a valid scope.

## [Tips](#tips)

-   Use a compound filter whenever you combine conditions, even if only two. It makes the logic explicit.
-   Keep each element of the array to one condition. Group related conditions in a nested filter.
-   Check each data point's metadata to be sure it supports the operator in the condition. See [Explore Data Points](https://developer-beta.morningstar.com/managed-investments-screener-api/explore-data-points).