filter-expressions
What it does
This skill explains how to write filter expressions for Lightdash query tools. It is for analysts and developers who build queries that need row filters or conditional metric filters.
When to use it
- ✓When you need to filter a Lightdash query to certain rows.
- ✓When you want a custom metric to count only rows that match a condition.
- ✓When you are searching field values with a filter in Lightdash.
Skill link
https://github.com/lightdash/lightdash/blob/main/packages/backend/src/ee/services/ai/skills/builtInSkills/filter-expressions/SKILL.mdCopy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.
How to use
The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.
Ready-to-paste message
For Claude Code, Codex or Cursor: run it in your project folder and the skill gets installed.
Download the SKILL.md and drop it into your agent’s skills folder.
Example of what to ask your AI
“Run a Lightdash query of total revenue, but only include orders from the North region with status completed.”
5 new skills a week. 1 minute to read.
How it works
The skill explains how to place each filter expression in the right category, such as dimensions, metrics or table calculations. It also warns against adding fields to the grouping when they are only used to filter rows.
Technical content (original SKILL.md)
Original text by the author, straight from GitHub.
Read this before writing filters for expression-enabled tools. It does not apply to tools whose schemas use structured filter objects. Follow each tool's input schema; this skill does not enable unavailable tools or filter modes.
Filter Expressions
For run_metric_query, set queryConfig.filters to null when no query filters are needed. Otherwise, dimensions, metrics, and tableCalculations are independent string expressions or null.
- A non-null category contains one raw string expression.
- Choose the category from discovered field metadata (its dimension/metric kind), never from a field name or whether a numeric field sounds metric-like. A raw numeric dimension belongs in
dimensions; only metrics and custom metrics belong inmetrics. - A field used only to restrict rows stays in its filter expression. Do not add it to
queryConfig.dimensionsunless the user asked to group by or display it: extra selected dimensions change aggregation and table-calculation grain. - Table calculations belong only in
tableCalculations. - Each category is flat and uses AND or OR, never both.
- The three categories combine implicitly with AND.
- Aggregation custom metric filters are flat AND expressions.
- Omit
search_field_values.filtersfor an unscoped search. When present, it is one flat dimension expression string and is AND-only. - The tool schema is authoritative for where each string is placed.
Raw placement examples:
dimensions: orders_status equals=completed,shipped AND orders_order_date inThePast=2{unit:weeks,completed:true}
dimensions (alternatives): orders_promo_code startsWith=VIP OR orders_promo_code endsWith=25
metrics: orders_total_order_amount greaterThan=100
tableCalculations: rank lessThanOrEqual=10
Join flat rules with AND or OR. Do not mix both connectors in one expression.
Bare scalars work. Double-quote reserved and whitespace/punctuation strings (apostrophes/parentheses); quote when unsure. Quoted commas/braces literal; backslash escapes. E.g.
orders_product_name equals="Coffee Filters (100pk)".Limits: 256 rules; 256 values including settings/rule; 256 characters/literal; 16384 characters/expression.
string
Grammar: <field> <operator form>
isNull [0 values]notNull [0 values]equals=<value>[,<value>...] [1+ values]notEquals=<value>[,<value>...] [1+ values]startsWith=<value>[,<value>...] [1+ values]endsWith=<value>[,<value>...] [1+ values]include=<value>[,<value>...] [1+ values]doesNotInclude=<value>[,<value>...] [1+ values]
number
Grammar: <field> <operator form>
isNull [0 values]notNull [0 values]equals=<value>[,<value>...] [1+ values]notEquals=<value>[,<value>...] [1+ values]lessThan=<value> [1 value]lessThanOrEqual=<value> [1 value]greaterThan=<value> [1 value]greaterThanOrEqual=<value> [1 value]inBetween=<first value>,<second value> [2 values]notInBetween=<first value>,<second value> [2 values]
date
Grammar: <field> <operator form>
isNull [0 values]notNull [0 values]equals=<value>[,<value>...] [1+ values]notEquals=<value>[,<value>...] [1+ values]lessThan=<value> [1 value]lessThanOrEqual=<value> [1 value]greaterThan=<value> [1 value]greaterThanOrEqual=<value> [1 value]inThePast=<count>{unit:<unit>,completed:<bool>} [1 count; settings required]notInThePast=<count>{unit:<unit>,completed:<bool>} [1 count; settings required]inTheNext=<count>{unit:<unit>,completed:<bool>} [1 count; settings required]inTheCurrent=<unit>[{toDate:true[,excludeToday:true]}] [1 unit; settings optional]notInTheCurrent=<unit>[{toDate:true[,excludeToday:true]}] [1 unit; settings optional]inBetween=<first value>,<second value> [2 values]- Units: days, weeks, months, quarters, years; completed=false includes partial, true completed only.
- Current-period bounds: {toDate:true} ends the current week/month/quarter/year at today ("month to date"); {toDate:true,excludeToday:true} ends it at yesterday (today's partial data excluded). Not valid for days.
boolean
Grammar: <field> <operator form>
isNull [0 values]notNull [0 values]equals=<value> [1 value]notEquals=<value> [1 value]
FAQ
Where do filters go?
Each filter goes in the category that matches its field, such as dimensions or metrics.
Will a filter change the grouping?
Only if you add the field to the grouping, so the skill says not to add filter-only fields to the grouping.
Are all filter modes available?
The skill follows each tool's own input schema, so only the modes that tool supports apply.
Details
Original description by the author
Author filter expressions for run_metric_query and search_field_values, including conditional custom metric filters.
repo: lightdash/lightdash
Popularity
- GitHub stars
- 6.2k
- Ranking position
- #14397
- License
- —
- Updated
- 11/2/2026
Comments
- …
More skills from this repository
breakup-pr
6.2kHelps your agent split a large pull request into smaller, stacked slices that can be reviewed and merged one at a time.
lightdash-agent-slack-messaging
6.2kHelps your agent write clear, friendly maintenance and activity reports for Lightdash administrators, based only on the evidence it has.
developing-in-lightdash
6.2kHelps your agent read, create and edit Lightdash dashboards and charts as JSON, including each chart type's settings.
mcp-artifact-integration
6.2kHelps your agent show Lightdash query results inside an HTML or React artifact, with loading, error and empty states handled.
Similar skills
gitcrawl
394kLets your agent search a saved archive of GitHub issues and pull requests, group duplicates, and check their current status on GitHub.
slacrawl
394kLets your agent search and count messages in a local Slack archive, check how fresh that archive is, and refresh it when needed.
goplaces
394kHelps your agent search for places, get their details and reviews, and resolve place names using Google Places, with JSON output for scripts.