Link to a Dashboard passing through multiple parameters

  • 25 July 2016
  • 8 replies

Note from our Docs team: Starting in 4.18, you can use Liquid variables to pass a query’s filter values into linked queries, dashboards, and Looks, please see this page in our documentation.

Is it possible to link from one dashboard to another (via any means - html/drill menus) and pass through not only the field selected, but also another parameter e.g. date filter.

In the case of html linking, we have something like this:

       sql: ${TABLE}.username
html: |
<span style="white-space: nowrap">{{ linked_value }}
<a href="/dashboards/common/user_list?username={{ value | url_encode }}&ReportPeriod=30+days+ago+for+30+days"><img src="/images/qr-graph-line@2x.png" height=20 width=20> </a></span>```

could we replace the hard-coded 30+days+ago+for+30+days with the date range that had been selected on the initial source dashboard?

8 replies

I’d love to know a good way to do this too… We’d love to link from one dashboard to another passing common filter/parameter values along for the ride so as to save our users from being re-prompted for the same values in the 2nd dashboard.

Userlevel 3

Hey @amcgrath83 and @Groovy_Growler!

So sorry that we didn’t get back to you about this!

Looker does not currently have any functionality that will carry dashboard filters through when linking to other dashboards. I’ll definitely share your support of this idea with the product team!

One of our analysts came up with a workaround using liquid that will grab the filters from the URL and pass them to the dashboard that is being linked to. It’s not pretty but may be worth some fiddling! You can play with it by throwing this block of code into the html parameter of whatever field you’re using to link. Measures will need to contain a drill_fields parameter for the link to be referenced.

Note that dimension links no longer contain filter values, so the following code will only work for measures. It can be applied to dimensions as well, but a measure link will need to be referenced instead. For example, you can replace {% assign url_split_at_f = link | split: 'f[' %} with {% assign url_split_at_f = count._link | split: 'f[' %} and put it in the html parameter of the dimension.

{% assign url_split_at_f = link | split: 'f[' %}
{% assign user_filters = link | truncate: 0 | replace: '...','' %}
{% assign continue_loop = link == true %}
{% for url_part in url_split_at_f offset:1 %}
{% if continue_loop %}
{% if url_part contains 'sorts' %}
{% assign part_split_at_sorts = url_part | split: 'sorts' %}
{% assign last_filter = part_split_at_sorts | first %}
{% assign user_filters = user_filters | append:'f[' %}
{% assign user_filters = user_filters | append:last_filter %}
{% assign continue_loop = link == false %}
{% else %}
{% assign user_filters = user_filters | append:'f[' %}
{% assign user_filters = user_filters | append:url_part %}
{% endif %}
{% endif %}
{% endfor %}

{% assign remove_last_ampersand = user_filters.size | plus: 2 %}
{% assign user_filters = user_filters | truncate: remove_last_ampersand %}
{% assign user_filters = user_filters | remove: '...' %}
{% assign user_filters = user_filters | replace: 'f[orders.created_date]', 'Date' %}
{% assign user_filters = user_filters | replace: 'f[products.brand_name]', 'Brand' %}
{% assign user_filter_split = user_filters | split: '&' %}
{% for filter in user_filter_split %}
{% assign filter_with_amp = filter | append: '&' %}
{% if filter_with_amp contains 'f['%}
{% assign user_filters = user_filters | remove: filter_with_amp %}
{% endif %}
{% endfor %}

Thans @Morgan I did actually get this working with help from one of your colleagues - unfortunately the fact that it has to be a measure didn’t work at all with our use case. It meant that the field which we normally kept on the left hand side of a large (20 column) table report had to go to the end - due to Looker’s measure/dimension grouping. And it also couldn’t be used with our pivoted reports - as it tried to also pivot the linked measure.

Is there any plan to update this so that it can be used on dimensions?

Userlevel 3

Hey @amcgrath83,

Linking filters between dashboards is a feature that we do intend on implementing at some point. Because of this, we don’t have any plans that relate to improving this workaround. Sorry that I don’t have an ETA or a better recommendation!

Userlevel 2

Is it now avaialble in new version or still be part of feature release? Just wanted to know before try out above mentioned option to transfer filter from one dashboard to another.

Userlevel 2

Hi @kshah7,

Thanks for checking in, this is not yet a feature available in looker. It is still something that is being scoped for future release but no ETA from product yet. If you run into any issues while implementing the work around don’t hesitate to hop on chat and we’ll help you through it!

Userlevel 3

In 4.18+, we allow folks to reference the current filters placed on a given dimension or measure and pass them along in the HTML, which works great for passing filters between dashboards.

The code looks like this: _filters[‘field_name’]

For example:

dimension: company {
type: string
sql: ${TABLE}.company

link: {
label: "Activity Overview"
url: "/dashboards/123?Date={{ _filters['user.created_at'] | url_encode }}"

At the top of this article I have added a link to our documentation on Passing a Query’s Filter Values Into a Link. Hope that helps!