links

LookML
Version

On this Page
Docs Menu

Go to Field Parameter List

Definition

The links parameter makes it easier and more useful to add Looker links and other external links to your dimensions. The form of a links parameter is:

- dimension: field_name links: - label: "desired label name" url: "desired_url" icon_url: "url_of_an_image_file" # Possibly more links

The links parameter has several child parameters.

  • label is the name of the link that you want to appear to users.
  • url is the URL that you want the link to go to. You can use Liquid variables to make the links dynamic, as described below.
  • icon_url is a URL, accessible to the user’s browser, that contains an image file. This makes it easier for users to understand, at a glance, where the link will take them. The icon_url parameter is not required if you do not want an icon. If you need corporate logos, try running a Google search with the pattern http://www.google.com/s2/favicons?domain=[company website of interest] to find images in the .ico format.

A common use of the links parameter is to direct users to related Looker explores or dashboards that aren’t automatically generated by using drill_fields. For example, this is one URL format often used to direct to a related Explore:

- dimension: city links: - label: "Another Awesome Explore" url: "/explore/model/explore_name?fields=view.field_1,view.field_2,&f[view.filter_1]={{ value }}" icon_url: "http://www.looker.com/favicon.ico"

That dimension would produce a link menu like the one below:

Link Behavior

When the user clicks on a link, Looker will open the link in either a new browser tab or in the same tab (or iframe, for embedded queries):

  • Absolute links (such as https://example.looker.com) will open in a new browser tab.
  • Relative links (such as /dashboards/456) will open in the same browser tab or iframe. Once the link is opened, the user can click Back in the browser to navigate back to the original query.

Liquid Variables

The links parameter supports Liquid variables to make links dynamic. For example, suppose you had an Artist Name dimension, and wanted the user to have the option of executing a Google search for that artist. You could create a dimension like the following:

- dimension: artist_name links: - label: "Google" url: "http://www.google.com/search?q={{ value }}" icon_url: "http://google.com/favicon.ico"

The user’s experience for this dimension link would look like this:

Passing a Query’s Filter Values Into a Link

Another Liquid variable supported by the links parameter is _filters['view_name.field_name']. This variable takes the values for a filter and passes them on to a linked query, dashboard, or Look. Here is an example of a dimension that uses the _filters variable in its links parameter:

- dimension: name links: - label: "Business Pulse By State Dashboard" url: "https://learn.looker.com/dashboards/694?State={{ _filters['users.state'] | url_encode }}"

In this example, if a user filters a query on the users.state dimension, the state(s) chosen by the user are captured and used in the link, so that the linked dashboard is automatically filtered by the same states as in the query. This is shown below, where the user has filtered a query by the state “California.” The link opens the dashboard, already filtered for California:

This also works for passing filter values to linked Looks and Explores:

dimension: name links: - label: "Average Order Profit Look" url: "https://learn.looker.com/looks/249?&f[users.state]={{ _filters['users.state'] | url_encode }}" - label: "User Facts Explore Explore" url: "https://learn.looker.com/explore/ecommerce/users?fields=users.id,users.name&f[users.state]={{ _filters['users.state'] | url_encode }}"

Also note that you can pass multiple filters using &, such as in the URLs specified below:

dimension: name links: - label: "Average Order Profit Look" url: "https://learn.looker.com/looks/249?&f[users.state]={{ _filters['users.state'] | url_encode }}&f[orders.date]={{ _filters['orders.date'] | url_encode }}" - label: "Business Pulse By State Dashboard" url: "https://learn.looker.com/dashboards/694?State={{ _filters['users.state'] | url_encode }}&Date={{ _filters['orders.date'] | url_encode }}"

Linking to Dashboards and Looks: Please keep in mind that a linked dashboard or Look must be configured with a filter that can accept the specified filter values. In the example above, the “Business Pulse by State” dashboard is configured with a filter on users.state, so that _filters['users.state'] information in the link can be applied to the dashboard.

If a dashboard or Look does not have a filter that can use the passed values, the link will still work, but the filter values will not be applied to the dashboard. For information on creating dashboard filters, see this page for LookML dashboards and this page for user-defined dashboards.

Linking to Explores: When setting up a URL for an Explore, open the Explore in a browser and add a filter. Then, from the Explore’s gear menu, select Share and then copy the Expanded URL. In the expanded URL you can see where the filter values are specified and replace them with your _filters variable. See this article for information on the parts of a query URL.

Still have questions?
Go to Discourse - or - Email Support
Top