Dashboards and reports
Dashboard filters
Filters let viewers narrow a whole dashboard at once: pick a time range, a team or an engineer, and every chart that uses that filter re-runs. This page explains the two ways a filter reaches a chart's query, how time and granularity are handled, every filter field, and the mistakes that make a chart silently ignore a filter.
What viewers see
Filters appear as chips above the charts:
- Time filters open a grid of durations, plus All time and Custom range... with From and To dates.
- Dropdowns list an All entry followed by the options. With more than 10 options a search box appears.
- Text filters are a free-text box that applies after you stop typing (or press Enter). Number filters take a number.
- A filter whose options list comes back with one entry or none is hidden, since there is nothing to choose.
- Clear resets every filter to its default.
The current selection is written into the page URL as f.<name>=<value> (for example f.team=Checkout), so copying the URL shares the filtered view.
How a filter reaches a chart
Filters do not run any query by themselves. Before each chart runs, the dashboard rewrites the chart's DSL using the current filter values. There are two mechanisms, and you can mix them on one dashboard.
| Mechanism | You write | Best for |
|---|---|---|
| Variables (recommended) | A variable: on the filter and [%name%] placeholders in your queries | Everything. You decide exactly where the value goes. |
| Injection | A scope: on the filter (global, auto or granularity) | Dropping a filter onto many existing charts without editing them |
solidafy validate warns when a filter uses scope: global or scope: auto and suggests a variable instead, because variables are explicit and predictable.
Variable filters
Give the filter a variable name and reference it in any query as [%name%]:
filters:
- id: time_range
variable: time_range
type: select
label: Time Range
default: 90d
options:
- { label: 7d, value: 7d }
- { label: 30d, value: 30d }
- { label: MTD, value: mtd }
- { label: 90d, value: 90d }
- { label: YTD, value: ytd }
- id: team
variable: team
type: select
label: Team
options_dsl: |
source("enrich.developers")
.filter(team != "Bot" and team != "")
.distinct(team)
charts:
- name: prs_by_engineer
title: PRs by engineer
tab: Overview
grid: { x: 0, y: 0, w: 12, h: 4 }
dsl: |
base = source("gh.pr_enriched", time: opened_at, granularity: 1d)
.join("enrich.developers", left_on: [author], right_on: [github_handle], type: inner)
.filter(team != "Bot")
base
.since(@time, "[%time_range%]")
.filter(team == "[%team%]")
.group_by([display_name])
.agg([count() as prs])
.chart(bar, x: display_name, y: prs)
What happens at run time:
- A value is selected:
[%team%]is replaced by the value, with quotes escaped. Write the quotes yourself in the query:team == "[%team%]". - Nothing is selected (All): the condition that holds the placeholder is removed. In
.filter(is_open == 1 and team == "[%team%]")onlyteam == ...goes andis_open == 1stays. If nothing is left, the whole.filter(...)call is removed. A placeholder inside anorgroup drops that whole group (narrowing half of anorwould change its meaning), and a filter whose entire body is such anoris removed outright. - A time window with nothing selected:
.since(@time, "[%time_range%]")is never removed. It falls back to the filter'sdefault, or to90dif there is no default. - A custom date range:
.since(@time, "[%time_range%]")becomes.between(@time, "<from>", "<to>").
Variables are substituted across the whole query, including preamble variables, so you can filter inside a join's input as well as in the final chain.
Tip: Put each filter variable in its own condition (
.filter(team == "[%team%]"), then.filter(region == "[%region%]")). It keeps the "remove when unset" behaviour easy to predict.
Which names work
A filter value is available under its variable, its column, and its label in lower case with spaces turned into underscores. A filter labelled "Time Range" therefore also answers to [%time_range%]. Using variable explicitly is clearer.
Time filters
A filter shows the time picker (durations, All time, Custom range...) when it has scope: global, or when every one of its static options is a duration. Durations are a number and a unit such as 7d, 30d or 365d, or one of mtd, qtd, ytd, last_month, last_quarter, last_year or last_N_months.
All time clears the selection. For a variable filter that means the chart falls back to the filter's default window (or 90d), as described above.
Cascading filters
A filter's options can depend on another filter. Reference the parent variable in the child's options_dsl and list it in depends_on:
- id: engineer
variable: engineer
type: select
label: Engineer
depends_on:
- time_range
- team
options_dsl: |
source("gh.pr_enriched")
.since(opened_at, "[%time_range%]")
.join("enrich.developers", left_on: [author], right_on: [github_handle], type: inner)
.filter(display_name != "" and team == "[%team%]")
.distinct(display_name)
When the parent changes, the child reloads its options. If the current choice is no longer in the list, it resets to its default. A [%var%] reference in options_dsl counts as a dependency even if you forget depends_on, but listing it keeps the file readable and lets solidafy validate check that the parent exists.
Never reference a filter's own variable in its own options_dsl: choosing a team would then shrink the team list to that one team.
Filters on some tabs only
Add tabs: to show a filter only on certain tabs:
- id: engineer
variable: engineer
type: select
label: Engineer
tabs:
- Engineer Spotlight
options_dsl: |
source("enrich.developers").distinct(display_name)
On other tabs the filter is hidden and its value is not applied. Leave tabs out to show the filter everywhere. solidafy validate reports a tab name that does not exist and a tab-scoped filter that no chart on that tab uses.
Injection filters
Injection filters do not need placeholders. The dashboard edits each chart's query for you, according to the filter's scope.
scope: global (time range)
- id: time
type: select
label: Time Range
scope: global
default: 30d
options:
- { label: 7d, value: 7d }
- { label: 30d, value: 30d }
- { label: 90d, value: 90d }
In the last statement of each chart, the duration in the first .since(<col>, "...") is replaced with the selected one, so .since(@time, "90d") becomes .since(@time, "30d"). If the chart has no .since(...) but its source(...) declares time:, a .since(@time, "...") is added right after the source. A custom date range becomes .between(@time, "<from>", "<to>").
scope: auto (dimension)
- id: team
type: select
label: Team
scope: auto
column: team
operator: "=="
options_dsl: |
source("enrich.developers").filter(team != "Bot" and team != "").distinct(team)
For each chart the dashboard:
- Looks for the column name as a whole word anywhere in the chart's DSL, including the preamble. If it is not there, the chart is skipped.
- Otherwise adds
.filter(team == "Checkout")to the last statement. It goes after the leading.since(),.between(),.select(),.join()and.filter()calls, and before the first other call (.group_by(),.agg(),.add(),.sort(),.limit(),.chart()).
operator can be == (default), !=, >, <, >=, <= or contains. Numeric-looking values are inserted without quotes. contains produces .filter(team.contains("value")).
If two injection filters are set, both are added.
scope: granularity
- id: granularity
type: select
label: Granularity
scope: granularity
options:
- { label: Daily, value: 1d }
- { label: Weekly, value: 1w }
- { label: Monthly, value: 1mo }
Replaces the granularity: value in the chart's source(...) call.
Granularity follows the time range
Whichever mechanism you use, once the time window is known the dashboard also adjusts bucket sizes to fit it:
| Window | Bucket |
|---|---|
| Less than 7 days | 1 hour |
| 7 to 92 days | 1 day |
| 93 to 183 days | 1 week |
| More than 183 days | 1 month |
It rewrites the granularity: in source(...), the unit in truncate(col, "..."), and the format in strftime(...) calls aliased as period or as granularity. Other strftime calls are left alone, so a formatted date column in a table keeps its format.
This only happens for windows written as a number plus a unit (7d, 90d). Named windows such as mtd keep the granularity in the query. Because the automatic adjustment runs last, it also overrides a scope: granularity filter whenever the chart has a numeric window.
Filter fields
| Field | Applies to | Meaning |
|---|---|---|
id | All | Unique id for the filter. solidafy validate and pipelines push require it and reject duplicates. |
label | All | Text on the chip. Required. |
type | All | select, text or number. Required. |
variable | Variable filters | The name used in [%name%] placeholders. |
default | All | Initial value, and the value Clear returns to. |
options | Select | Static list of { label, value } entries. |
options_dsl | Select | A DSL query whose results become the options. |
value_field, label_field | Select with options_dsl | Which result columns hold the option value and its label. Without them, the first column is used for both. |
depends_on | Select with options_dsl | Variables this filter's options depend on. |
tabs | All | Tab names to show the filter on. Empty or missing means every tab. |
placeholder | Text | Placeholder text in the input. |
scope | Injection filters | global, auto or granularity. |
column | Injection filters | Column to filter on (scope: auto). |
operator | Injection filters | ==, !=, >, <, >=, <= or contains. |
Pitfalls
The chart ignores the filter. For variable filters, the chart's query simply does not contain [%name%]. solidafy validate warns about a variable that no chart uses. For scope: auto, the column name does not appear anywhere in the DSL text, so injection is skipped. This often happens when a joined table brings the column in but the query never names it. Make it visible with a condition that is always true, such as .filter(team != "").
The chart breaks when a filter is set. With scope: auto, the filter is added to the last statement. If that statement joins in the filtered column, the filter can land before the join and reference a column that does not exist yet. Move the join into a preamble variable (see The preamble pattern).
A preamble total does not follow the time range. Injection filters only rewrite the last statement. A preamble variable like day_totals = source(...).since(date, "90d") keeps its 90 days. If that number should follow the dashboard, use a [%time_range%] placeholder in the preamble too: variable filters apply everywhere.
Goals change with the filter. They will not, as long as they live in a preamble @goal = ... variable without placeholders. That is usually what you want.
"All time" still shows 90 days. For variable filters, clearing a time selection falls back to the filter's default or 90d. Add a long option such as 365d if viewers need a long view.
A child filter disappears. A cascading filter is hidden when its parent narrows it to one option or none. Clearing the parent brings it back.
Testing filters
solidafy validate <file>catches unused variables, unknowndepends_onparents and bad tab names.solidafy test <file>runs every chart with each variable filter'sdefaultsubstituted. If a chart fails with the defaults, it is retried with the[%var%]conditions removed, and reported as passing if it works then. That tells you the query is sound and only the test values matched nothing.- In the portal, set each filter to a specific value and confirm the charts change. A chart that shows the same number with and without a filter is not using it.
