Dynamically change the time series with filters

Hi everyone, I’m new to Looker, and I need to modify a dashboard in the following way.
At the moment, I have a visualization tile representing net sales per week (week on the x-axis, sales on the y-axis). I can also group the sales by month in the explore tab.

What I need to achieve is to change the time granularity from weeks to months, directly in the dashboard. Basically I want the first chart in the image to change into the second one, to avoid displaying a too many charts at the same time (because I need the same behaviour on many different tiles in the same dashboard).

Is there a way to achieve this using filters/buttons?

Thanks in advance

You can achieve that by using parameters and liquid variables:

parameter: date_granularity {
  type: unquoted
  allowed_value: {
    label: "Break down by Day"
    value: "day"
  }
  allowed_value: {
    label: "Break down by Month"
    value: "month"
  }
}

dimension: dynamic_date {
  type: string
  label_from_parameter: date_granularity
  sql:
    {% if date_granularity._parameter_value == 'day' %}
      ${created_date}
    {% elsif date_granularity._parameter_value == 'month' %}
      ${created_month}
    {% else %}
      ${created_date}
    {% endif %};;
}
1 Like