Filter dashboard by default on last 7 days

How can I filter dashboard on last 7 days by default but also give the date option.

Hi @Anum
Use the "Default filter value":

I want to create a filter on single date from start date to end date and which filters by default on last 7 days, i.e., last seven days to current date when the date is not provided.

@flamber can we fix this syntax for mysql?

Something along the lines
where created_at>{{default last 7 days}} and created_at<= {{default today}}

Here, last 7 days is a starting time and default today is the ending time. I want it to filter it by default on last 7 days but if it should also work on the given date.

@Anum Post "Diagnostic Info" from Admin > Troubleshooting.

Failed query log?


"browser-info": {
"language": "en-US",
"platform": "Win32",
"userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.85 Safari/537.36",
"vendor": "Google Inc."
"system-info": {
"file.encoding": "UTF-8",
"": "OpenJDK Runtime Environment",
"java.runtime.version": "11.0.10+9-LTS",
"java.vendor": " Inc.",
"java.vendor.url": "",
"java.version": "11.0.10",
"": "OpenJDK 64-Bit Server VM",
"java.vm.version": "11.0.10+9-LTS",
"": "Linux",
"os.version": "4.14.225-169.362.amzn2.x86_64",
"user.language": "en",
"user.timezone": "UTC"
"metabase-info": {
"databases": [
"hosting-env": "unknown",
"application-database": "mysql",
"application-database-details": {
"database": {
"name": "MySQL",
"version": "5.7.34-log"
"jdbc-driver": {
"name": "MariaDB Connector/J",
"version": "2.6.2"
"run-mode": "prod",
"version": {
"date": "2020-12-03",
"tag": "v0.37.3",
"branch": "release-x.37.x",
"hash": "2f1e783"
"settings": {
"report-timezone": null


# Total orders
Select count(*) as TotalOrders
From order 
where [[and created_at>={{start_date}} and created_at<={{end_date}}]]

If date is not provided it should find from current to last seven days, i.e., start_date = 21April,2021 and end_date=28April,2021

@Anum Then you can use Complex Default Values in the Optional Clauses:

Select count(*) as TotalOrders
From order 
where 1=1
[[and created_at>={{start_date}} and created_at<={{end_date}} #]] and created_at>=(DATE(NOW()) + INTERVAL -6 DAY) and created_at<=DATE(NOW())

Thank you @flamber. You are truly amazing.