Skip to content

Filtering

The filter statement keeps rows that match a condition. Rows that do not match are dropped.

with sales as active
    filter status == "active"

Comparison operators

Operator Meaning
== Equal
!= Not equal
> Greater than
< Less than
>= Greater than or equal
<= Less than or equal
filter price > 100
filter quantity != 0
filter status == "active"
filter score >= 0.9
filter discount <= 0.5

Logical operators

Combine conditions with and / or:

filter amount > 1000 and category == "premium"
filter status == "active" or price > 500
filter region == "North" and status == "active" and amount > 100

Note

and binds more tightly than or. Use parentheses if you need explicit grouping — though in practice most filters are simple enough that this doesn't arise.

Membership — in / not in

Test whether a value is in a list:

filter region in ["North", "South", "East"]
filter category not in ["test", "draft"]

Use a Python variable for the list:

valid_regions = ["North", "South"]
filter region in :valid_regions

Range — between

Test whether a value falls within an inclusive range:

filter price between [100, 500]
filter score between [0.8, 1.0]

String matching

Operator Meaning
contains "x" String contains substring
not contains "x" String does not contain substring
startswith "x" String starts with prefix
endswith "x" String ends with suffix
filter product contains "Laptop"
filter name not contains "test"
filter event startswith "login"
filter filename endswith ".csv"

Python variable references

Any filter value can be a Python variable, prefixed with ::

min_price = 100
target_region = "North"
filter price > :min_price
filter region == :target_region

Multiple filter lines

Multiple filter lines under the same with block are applied in sequence (AND logic):

with sales as result
    filter status == "active"
    filter amount > 500
    filter region in ["North", "South"]