# By expression

## Objective

Enable developers the flexibility to define filtering logic using Javascript.&#x20;

This is ideal when there is a need to fine tune the filtering process to the needs of the use case.

## Uses

There are various uses for this filter such as:

1. <mark style="color:green;">**In software development**</mark>\
   Enable developers to create complex filtering logic by combining multiple conditions within a single filter process, simplifying the pipeline.
2. <mark style="color:green;">**In data science**</mark>\
   Use layered filters to refine datasets, allowing specific data points to pass through for targeted analysis.
3. <mark style="color:green;">**In cybersecurity**</mark>\
   Apply multi-layered filters to detect specific patterns or anomalies in real-time, improving threat detection accuracy.

## Example & DSL attributes

This will provide all `IBM` events to the next processors.

{% hint style="info" %}
Top level `StreamEvent` attributes are not available within the scripting processing context.
{% endhint %}

```yaml
filter:
  expression: "(typeof symbol !== 'undefined' && symbol === 'IBM') ? true : false;"
```

### Attributes schema

<table><thead><tr><th width="193">Attribute</th><th width="217">Description</th><th width="219">Data Type</th><th data-type="checkbox">Required</th></tr></thead><tbody><tr><td>expression</td><td>A valid Javascript expression that returns a boolean value</td><td>String</td><td>true</td></tr></tbody></table>


---

# Agent Instructions: Querying This Documentation

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.fractalworks.io/joule/components/processors/filters/by-expression.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
