metabase / metabase/metabase

Cannot bind relative date filter on dashboard to sql variable of date type

Open
#70,178 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

.Frontend .Team/UXWest Priority:P3 Reporting/Dashboards Reporting/Dashboards/Filters & Parameters Type:Bug
Dominant language
Clojure
Stars
49.3k
Forks
6.8k
Avg merge
1d 13h
Merged PRs (30d)
653

Description

Describe the bug

Relative date dashboard filter can only be bound to SQL variable of Field Filter type.

The workaround is to use single date type but that widget lacks relative date selection and relative default value.

To Reproduce
  1. Create dashboard
  2. Add SQL Question with {{since}} variable of Date type
  3. Save and back
  4. Add dashboard filter Since of relative date type
  5. Attempt to bind it to previously defined variable

Not possible, have to change dashboard filter to single date.

A date variable in this card can only be connected to a time type with the single date option.

Image
Expected behavior

It should be possible to bind relative date filter to Date variables.

Previous 7 days would become current_timestamp - interval '7 days'

Or perhaps Relative and Single date modes should be merged and the widget allow both types of selections.

Logs

No response

Information about your Metabase installation
{
  "browser-info": {
    "language": "en-US",
    "platform": "MacIntel",
    "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/145.0.0.0 Safari/537.36",
    "vendor": "Google Inc."
  },
  "metabase-info": {
    "databases": [
      "postgres",
      "h2"
    ],
    "run-mode": "prod",
    "plan-alias": "",
    "version": {
      "date": "2026-02-24",
      "tag": "v0.58.7.4",
      "hash": "93cd8a0"
    },
    "settings": {
      "report-timezone": null
    },
    "hosting-env": "unknown",
    "application-database": "h2",
    "application-database-details": {
      "database": {
        "name": "H2",
        "version": "2.1.214 (2022-06-13)"
      },
      "jdbc-driver": {
        "name": "H2 JDBC Driver",
        "version": "2.1.214 (2022-06-13)"
      }
    }
  },
  "system-info": {
    "file.encoding": "UTF-8",
    "java.runtime.name": "OpenJDK Runtime Environment",
    "java.runtime.version": "21.0.10+7-LTS",
    "java.vendor": "Eclipse Adoptium",
    "java.vendor.url": "https://adoptium.net/",
    "java.version": "21.0.10",
    "java.vm.name": "OpenJDK 64-Bit Server VM",
    "java.vm.version": "21.0.10+7-LTS",
    "os.name": "Linux",
    "os.version": "6.6.119-0-virt",
    "user.language": "en",
    "user.timezone": "GMT"
  }
}
Severity

Annoying

Additional context

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the dashboard and SQL Question steps with a Date variable and a relative date filter. Trace where dashboard filter bindings reject Date variables and how relative values are converted for SQL. Done means the binding succeeds and a selection such as “Previous 7 days” is passed as the expected date expression, with coverage for the regression.

Written by the indexing model from the issue text.

Assessment

Tech stack
clojure, sql
Domain
backend, databases, frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.