> For the complete documentation index, see [llms.txt](https://doc.moost.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://doc.moost.io/platform-manual/rules/rule-language/functions/filter.md).

# FILTER

### Description

Filter data on a *vector,* *grouped scalar* or *grouped vector*, by comparing with a threshold. Only data which fulfills that boolean condition is kept.

### Filter(Vector\<any>, Scalar\<Text>, Scalar\<any>)

```java
FILTER(vector: Vector<any>, 
       comparisonSymbol: Scalar<Text>, 
       threshold: Scalar<any>): Vector<any>
```

Filter data in the given *vector* by comparing with the threshold.

#### Parameters

<table><thead><tr><th width="203">Parameter</th><th>Description</th></tr></thead><tbody><tr><td>vector</td><td>A <em>vector</em> whose data is to be filtered</td></tr><tr><td>comparisonSymbol</td><td>The comparison symbol. One of: <code>&#x3C;</code>, <code>&#x3C;=</code>, <code>=</code>, <code>!=</code>, <code>>=</code>, <code>></code></td></tr><tr><td>threshold</td><td>A <em>scalar</em> which is used to filter data.</td></tr></tbody></table>

#### Returns

*Vector* of same type as from the first function parameter, with filtered data.

### Examples

Filter events, so that only values > 1000 are kept in the vector.

```java
FILTER($GridPowerConsumption, '>', 1000)
```

***

### Filter(GroupedScalar\<any, any>, Scalar\<Text>, Scalar\<any>)

```java
FILTER(groupedScalar: GroupedScalar<any, any>, 
       comparisonSymbol: Scalar<Text>, 
       threshold: Scalar<any>): GroupedScalar<any, any>
```

Filter data in the given *grouped scalar* by comparing with the threshold. Empty groups are removed from the *grouped scalar.*

#### Parameters

<table><thead><tr><th width="203">Parameter</th><th>Description</th></tr></thead><tbody><tr><td>groupedScalar</td><td>A <em>vector</em> whose data is to be filtered.</td></tr><tr><td>comparisonSymbol</td><td>The comparison symbol. One of: <code>&#x3C;</code>, <code>&#x3C;=</code>, <code>=</code>, <code>!=</code>, <code>>=</code>, <code>></code></td></tr><tr><td>threshold</td><td>A <em>scalar</em> which is used to filter data.</td></tr></tbody></table>

#### Returns

*Grouped scalar* of same type as from the first function parameter, with filtered data.

### Examples

Filter events in the *grouped scalar*, so that only values > 1000 are kept in the vector.

```java
FILTER(MIN(GROUP_BY_DEVICE($PowerConsumption)), '!=', 0)
```

***

### Filter(GroupedVector\<any, any>, Scalar\<Text>, Scalar\<any>)

```java
FILTER(groupedVector: GroupedVector<any, any>, 
       comparisonSymbol: Scalar<Text>, 
       threshold: Scalar<any>): GroupedVector<any, any>
```

Filter data in the given *grouped vector* by comparing with the threshold. Empty groups are removed from the *grouped vector.*

#### Parameters

<table><thead><tr><th width="203">Parameter</th><th>Description</th></tr></thead><tbody><tr><td>groupedVector</td><td>A <em>vector</em> whose data is to be filtered.</td></tr><tr><td>comparisonSymbol</td><td>The comparison symbol. One of: <code>&#x3C;</code>, <code>&#x3C;=</code>, <code>=</code>, <code>!=</code>, <code>>=</code>, <code>></code></td></tr><tr><td>threshold</td><td>A <em>scalar</em> which is used to filter data.</td></tr></tbody></table>

#### Returns

*Grouped vector* of same type as from the first function parameter, with filtered data.

### Examples

Filter events, so that only values > 1000 are kept in the *grouped vector*.

```java
FILTER(GROUP_BY_DEVICE($PowerConsumption), '<=', 200)
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://doc.moost.io/platform-manual/rules/rule-language/functions/filter.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
