Docs / Build Workflow

Filter — cutoff_date

When to use cutoff_date

Use cutoff_date when the analysis is "everything from the start of the month up to a chosen day" — month-to-date revenue, monthly closing reports, "as-of" snapshots. The user picks a single date; Looky automatically sends both date_from (the first day of that month) and date_to (the chosen date) as parameters.

Use date_range when the user needs to pick both endpoints freely. Use date_range_preset when the choice is among named presets like "last 30 days" or "this quarter".

Required fields

  • type: cutoff_date

Optional fields

  • id — internal identifier for the filter.
  • label — display label above the picker.
  • param — the parameter name the resolved cutoff date itself is additionally sent under (defaults to the filter's id, then to cutoff_date). The derived window always arrives as date_from / date_to regardless.
  • default — date token (see below) or ISO date string. Defaults to "{{today}}".
  • granularity — controls how date_from is derived from the chosen date. One of day, month (default), quarter, year. With day, date_from equals the chosen date (one-day window). With month, the first day of the chosen date's month. With quarter, the first day of the chosen date's calendar quarter (Jan, Apr, Jul, or Oct). With year, January 1 of the chosen date's year. Honored at both dashboard and visualization level.

Maximum selectable date

The picker offers every day up to and including today, in the workspace timezone, and none after it. The default decides where the filter opens: {{today}} for the day in progress, {{yesterday}} for the last closed day — the choice for end-of-day summaries, PDFs and period closes — or a literal date.

Date tokens for defaults

These tokens resolve against the workspace timezone (ui.timezone in workspace.yml, falling back to the instance default):

  • {{today}}
  • {{yesterday}}
  • {{start_of_week}} / {{end_of_week}}
  • {{start_of_month}} / {{end_of_month}}

Anything not in this list is treated as a literal ISO date string (e.g. "2024-12-31").

How the value reaches the Malloy query

The chosen date sets two parameters on every query that the filter applies to:

  • date_from — derived from the chosen date according to granularity (defaults to first day of its month).
  • date_to — the chosen date itself.

Your Malloy model declares those two parameters and uses them in where: clauses:

##! experimental.parameters

source: ec_orders(
  p_date_from::date is @2024-01-01,
  p_date_to::date   is @2024-12-31
) is ecommerce.table('bigquery-public-data.thelook_ecommerce.order_items') extend {
  view: revenue_mtd is {
    where:
      created_at::date >= p_date_from
      and created_at::date <= p_date_to
    aggregate:
      revenue is sum(sale_price)
  }
}

Adapter differences

Both date_from and date_to are date / timestamp parameters. On BigQuery they bind natively. On Postgres and MySQL the model must use the @param placeholder pattern in the underlying SQL — see the source adapter comparison and Malloy support.

Worked examples

Default cutoff is today:

filters:
  - type: cutoff_date
    label: Cutoff
    default: "{{today}}"

Default cutoff is end of last month (for monthly close reports):

filters:
  - type: cutoff_date
    label: Closing date
    default: "{{end_of_month}}"

Default cutoff is a literal date (for a fixed historical snapshot):

filters:
  - type: cutoff_date
    label: As of
    default: "2024-12-31"