Question

Templated Filters/Liquid Parameters to generate a rolled up/simple dashboard filter for a user?

  • 2 September 2019
  • 1 reply
  • 134 views

I am creating a dashboard wherein I’d want a user to be able to flick between two views easily – however each view requires selecting 3 items that fall under a dimension named line. Line can be equal to = this year, last year, targets, % var, and % change.


Each dashboard should have our dimension “line” filtered to 3 items.

Dashboard 1: this year, last year, & % change.

Dashboard 2: this year, target, & % var.

I want to create a ‘rollup’ filter that’ll be named YoY OR vs. target that’ll apply these filters without a user needing to know to filter line to 3 options.


I’ve read this documentation + this too but nothing has worked. I’ve found something on discourse too, but it involves a case statement, the problem I’m finding is that they all tend to apply to thresholds of measures/how to handle a measure (min/max/etc) as opposed to just rolling up a few filter selections into one master one…?


Is there an easier way of doing this, please?


1 reply

Userlevel 7
Badge +1

The first thing that comes to mind here is using a sql_always_where: at the model level and some liquid if logic to flick several filters on/off based on the state of a filter.


If you define a parameter


parameter: rollup {
type: string
allowed_value: {
label: "YoY"
value: "yoy"
}
allowed_value: {
label: "Vs. Target"
value: "target"
}

then you can reference it in the explore:


explore: great_explore {
sql_always_where:
{% if rollup._parameter_value == "yoy" %}
date = this year AND
date = last year AND
dimension = % change
{% elsif rollup._parameter_value == "target" %}
date = this year AND
dimension = line AND
dimension = % var
{% endif %}

I’m not sure if I fully understand your use case, but I hope this sql_always_where idea might be useful! Would be curious to hear what you wind up with.

Reply