Using URLs and Query Parameters

An updated version of the html is below.

Please note that dimension links no longer contain filter values. The following code should work as-is for measures, but for dimensions, you’ll need to just grab a measure link as opposed to the dimension link. For example, you can replace {% assign url_split_at_f = link | split: 'f[' %} with {% assign url_split_at_f = count._link | split: 'f[' %}. Also note that any measure you reference this way must have a drill_fields parameter for a link to be generated.

{% 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 %}
          {{user_filters}}

1 Like

The code above this post is obsolete, as we now 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 }}"
  }
}

1 Like

What Permission Set is required for viewing these field links? It’s not explicitly called out as ‘explore’, but I believe that may be the case.

It’s actually a “see_drill_overlay” action that is automatically checked off when you include ‘explore’, but is not in ‘explore’'s sub-tree.

@maxcorbin Is it possible to use the link parameter in a model and pass a filter from a dashboard, which is based on a field from another model? I have tried a lot of different modifications to the URL but it doesn’t seem to pass the values of the filter which is based on another model.

Can you please show output results as image as well so that new learners can easily understood

1 Like

We use & to get an AND filter, what if i want to use an OR filter , what should i use then ?