Dashboard Button link to get filter values and auto-apply in Look

Could you help me with one tricky functionality I am trying to implement in Looker.

Let me provide the background to be able to recommend me options.

I have a dashboard with a button, that is linked to Look. I have a filter "shipping_address_country_code" on the dashboard and in the Look. 

My task: get filter value from Dashboard and auto apply to the Look. The tricky moment is that I want to do it NOT in the dimension but in Button URL.

So the use case is

1. User opens the dashboard

2. User selects a filter "shipping_address_country_code" = NL

3. User clicks on the button

4. User sees Look

5. User sees filter "shipping_address_country_code" on the Look with auto-applied filter value "shipping_address_country_code" = NL

So the code example from LookML model of the dashboard. 

#Button Send the selection
  - type: button
    name: button_243
    rich_content_json: '{"text":"Send selection","description":"Send your selection
      to Google Ads after the final check of your customers","newTab":true,"alignment":"center","size":"large","style":"FILLED","color":"#80868B",
      "href":"https://crystalloids.eu.looker.com/looks/56?Orders={{_filters[orders.shipping_address_country_code]| url_encode}}&f[orders.shipping_address_country_code]"}'
 

One more option I tried

#"href":"https://crystalloids.eu.looker.com/looks/56?fields=orders.shipping_address_country_code&f[orders.shi..."}'

These code examples work for the dimension but not for the button. Could you consult me if my scenario is can be implemented and if yes, what should I correct in the code to reach the result.

Thank you in advance! 

0 6 2,365
6 REPLIES 6

Hey did you get this working? I’m trying to do the exact same thing. Please let me know thank you!!!

+1 - trying to figure out how to pass parameters into button URLs dynamically

clathrop
Participant II

I know in the original reply you stated that you don’t want to use a dimension, but you can replicate a button pretty well using a dimension. You can set up a button using a “single value” type tile and use the HTML attribute. In this example I’m using a parameter value, not a filter, but the idea is the same. 

dimension: a_dynamic_button {
type: string
sql: '' ;;
html:
{% assign your_param = size_of_range._parameter_value %}
<a href='https://coldborecapital.looker.com/dashboards/289?Number%20of%20Trailing%20Days={{ your_param }}'>
<span style='border:1px solid rgb(168, 50, 141); border-radius: 5px; background: rgba(186, 45, 154); color: rgb(255,255,255); padding: 3px;'>Click Me</span></a> ;;
}

In this example, I set a variable named your_param first. It is pulling a value from a filter named size_of_range. Then using {{ your_range }} I put the rendered value into the URL parameter of the dashboard I’m linking to.

@clathrop Thanks for this, do you know if there is a similar way to use the current dashboards filter values as input to the href link here instead of a parameter?

@jonvitale-16770 replace the parameter in the braces with a liquid filter variable " _filters['view_name.field_name'] " for the field you will be filtering in your dashboard, and that should do the trick. Adapting @clathrop 's example, it would look something like this:

dimension: button_243 {
type: string
sql: '' ;;
html:
<a href='https://crystalloids.eu.looker.com/looks/56?Orders={{_filters['Borders.shipping_address_country_code']}}'target="_blank">
<span style='border:1px solid rgb(128, 134, 139); border-radius: 5px; background: rgba(128, 134, 139); color: rgb(255,255,255); padding: 3px;'>Send selection</span></a> ;;
 

 

Hello, do you need to create a filter inside your view file ? or can you just select a dimension that is filtered by a user to use in your button ? 

Top Labels in this Space
Top Solution Authors