Question

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

  • 24 November 2022
  • 3 replies
  • 232 views

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.shipping_address_country_code]={{orders.shipping_address_country_code._value}}"}'

 

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! 


3 replies

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

Userlevel 1

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.

Reply