# Using URLs and Query Parameters

**URL:** <https://discuss.google.dev/t/using-urls-and-query-parameters/115290>\
**Category:** Looker\
**Created:** [March 30, 2015, 11:09pm UTC](https://discuss.google.dev/t/using-urls-and-query-parameters/115290 "2015-03-30T23:09:16Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Zam](https://avatars.discourse-cdn.com/v4/letter/z/e95f7d/32.png) [@Zam](https://discuss.google.dev/u/Zam)\
**Post date:** [March 30, 2015, 11:09pm UTC](https://discuss.google.dev/t/using-urls-and-query-parameters/115290/1 "2015-03-30T23:09:16Z")

</div>

### Background on the URL

In Looker **pre-3.18** , the url is a long list of parameters which includes the fields, filters, filter values, pivots, row limits, column limits, total settings, row total settings, and sorts.

In Looker **3.18 and later** the url is hashed and stored in a slug, which is used to generate the query. No matter the version, the following parameters can be used to generate queries.

### Parameters and How to Use Them

> **Important:** Any field in the **pivots** or **sorts** list must also reside in the **fields** list.

A general url with all of the parameters:

```auto

https://company.looker.com/explore/model/explore_name?fields=view.field_1,view.field_2,view.count
&f[view.filter_1_dimension]={{ value }}
&f[view.filter_2_on_date]=last+60+days
&pivots=view.field_2
&limit=50
&column_limit=20
&total=true
&row_total=right
&sorts=view.field_1,view.count+desc

```

### Explanations for each parameter:

- **fields** : The list of fields used. You may also use a **set** from a view as such `fields=view_name.set_name*`
- **f[]**: Declaration of a filter with it’s respective value. Any additional filter is declared with another `f[view.dimension_name]`
- **pivots** : The set of dimensions you want to pivot in the look.
- **limit** : The limit for the query. Any value \> 5000 will default to 5000.
- **column\_limit** : The column limit. This only exists if there is at least one pivoted dimension.
- **total** : Column totals toggle. The value for this is either **true** or **false** (off or on, respectively).
- **row\_total** : Row total toggle. The value for this is either **true** or **false** (off or on, respectively).
- **sorts** : The fields to sort on. Default or no value entered is ascending sort.

# Note (October 2017):

> 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:\> `auto> dimension: company {> type: string> sql: ${TABLE}.company> > `\> link: {\> label: “Activity Overview”\> url: “/dashboards/123?Date={{ \_filters[‘user.created\_at’] | url\_encode }}”\> }\> }\> `auto> > `

---

<div class="post-metadata">

**Author:** ![cutler](https://avatars.discourse-cdn.com/v4/letter/c/e68b1a/32.png) [@cutler](https://discuss.google.dev/u/cutler)\
**Post date:** [April 8, 2015, 3:18am UTC](https://discuss.google.dev/t/using-urls-and-query-parameters/115290/2 "2015-04-08T03:18:44Z")

</div>

Super cool! Do you know how one would add a semi-variable filter?

For example, say I want to filter on something occurring in the past 90 days. The filter will be less variable than a `{ { value } }`, but a date that qualifies as in the “past 90 days” is certainly not going to be fixed.

If I create a Look and take a look at the filters, I see what appear to be key-value pairs for today’s date (represented as 2015-04-07) and a 90 day offset. Sure, I could bake this into my URL, but it’ll give me the wrong data for any day other than today.

Know how to solve this?

---

<div class="post-metadata">

**Author:** ![Zam](https://avatars.discourse-cdn.com/v4/letter/z/e95f7d/32.png) [@Zam](https://discuss.google.dev/u/Zam)\
**Post date:** [April 8, 2015, 2:48pm UTC](https://discuss.google.dev/t/using-urls-and-query-parameters/115290/3 "2015-04-08T14:48:24Z")

</div>

Hey Cutler!

The way to input values such as ‘past 90 days’ into a filter is by simply replacing {{ value }} in the example above with ‘past+90+days’. Essentially, you may enter a string value for a filter keeping in mind to replace spaces with '+'s. The example url would be:

`https://company.looker.com/explore/model/explore_name?fields=view.field_1&f[view.filter_1_dimension]=last+90+days`

---

<div class="post-metadata">

**Author:** ![anonymous8](https://avatars.discourse-cdn.com/v4/letter/a/7cd45c/32.png) [@anonymous8](https://discuss.google.dev/u/anonymous8)\
**Post date:** [August 11, 2015, 5:04pm UTC](https://discuss.google.dev/t/using-urls-and-query-parameters/115290/4 "2015-08-11T17:04:21Z")

</div>

Hey team,

How do I use the html tags to carry over a filter to my linked URL? I’m writing something that looks like this:  
`/explore/production/order?fields=cpt_metrics.cpt_code&f[order.completed_date]={{ value }}`

The `{{ value }}` is pulling the value of the cell (which is a measure) but I want to pull the value of the filter on the source query. Basically, I want to do exactly what Zach responded above, except I want the ‘last 90 days’ to be configurable by the user in that source query. Any way to do this?

---

<div class="post-metadata">

**Author:** ![Brett\_Sauve](https://avatars.discourse-cdn.com/v4/letter/b/9fc348/32.png) [@Brett\_Sauve](https://discuss.google.dev/u/Brett_Sauve)\
**Post date:** [August 13, 2015, 11:32pm UTC](https://discuss.google.dev/t/using-urls-and-query-parameters/115290/5 "2015-08-13T23:32:01Z")

</div>

Hey @Leland\_Robbins , there isn’t currently a straightforward way to do this, but I’ve added you to the feature request for it.

However, you might be able to do this with some fancy liquid templating. Fair warning, this code is **completely** absurd, and a real developer would probably laugh hysterically at me ��. However, this seemed to work in the situation I tested:

```auto
html: |
  {% assign url_split_at_f = link | split: '&f' %}
  {% assign user_filters = '' %}
  {% assign continue_loop = 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 = false %}
      {% else %}
        {% assign user_filters = user_filters | append:'&f' %}
        {% assign user_filters = user_filters | append:url_part %}
      {% endif %}
    {% endif %}
  {% endfor %}

  <a href="http://whatever?{{ user_filters }}">My Link</a>

```

Liquid just has limited string parsing abilities, which makes this clunky. I wish it had a `find` or `search` type of function.

In any case, essentially what I’m doing here is using the `{{ link }}` value, which is the link Looker normally generates for drilling. Then I am parsing that URL for the filters that the user has added.

Unfortunately this will only work if the user changes a filter _and also runs the query_. If they don’t run the query the value that they change to will not dynamically be reflected in the URL I’m building.

---

<div class="post-metadata">

**Author:** ![anonymous8](https://avatars.discourse-cdn.com/v4/letter/a/7cd45c/32.png) [@anonymous8](https://discuss.google.dev/u/anonymous8)\
**Post date:** [September 2, 2015, 3:50pm UTC](https://discuss.google.dev/t/using-urls-and-query-parameters/115290/6 "2015-09-02T15:50:59Z")

</div>

Just a note on this… I had a value with embedded characters so the generated url wouldn’t work. I needed to do this…

```auto
<a href="/dashboards/ecommerce/category_lookup?category={{ value | url_encode | replace: '&','%26' }}

```

…to get a value url.

---

<div class="post-metadata">

**Author:** ![anonymous8](https://avatars.discourse-cdn.com/v4/letter/a/7cd45c/32.png) [@anonymous8](https://discuss.google.dev/u/anonymous8)\
**Post date:** [January 26, 2016, 2:38am UTC](https://discuss.google.dev/t/using-urls-and-query-parameters/115290/7 "2016-01-26T02:38:09Z")

</div>

Hey All:

Is there a solution to @Leland\_Robbins request? I need the same functionality now (pulling the value of the filters into the HTML tag), and since the original question was in August, I was hoping it would be a feature by now.

Thanks!

---

<div class="post-metadata">

**Author:** ![Zam](https://avatars.discourse-cdn.com/v4/letter/z/e95f7d/32.png) [@Zam](https://discuss.google.dev/u/Zam)\
**Post date:** [January 26, 2016, 10:17pm UTC](https://discuss.google.dev/t/using-urls-and-query-parameters/115290/8 "2016-01-26T22:17:37Z")

</div>

@ArvindR It is not yet possible, but a recent discussion with eng notes that this should be achievable in todays world. No eta on priority/timing of the feature but we’ll keep you all posted.

---

<div class="post-metadata">

**Author:** ![anonymous8](https://avatars.discourse-cdn.com/v4/letter/a/7cd45c/32.png) [@anonymous8](https://discuss.google.dev/u/anonymous8)\
**Post date:** [January 28, 2016, 6:50pm UTC](https://discuss.google.dev/t/using-urls-and-query-parameters/115290/9 "2016-01-28T18:50:42Z")

</div>

+1 for adding it as a feature. Would be so helpful to piece together a number of different looks on the same dashboard via a specific filter.

---

<div class="post-metadata">

**Author:** ![anonymous8](https://avatars.discourse-cdn.com/v4/letter/a/7cd45c/32.png) [@anonymous8](https://discuss.google.dev/u/anonymous8)\
**Post date:** [February 19, 2016, 11:44pm UTC](https://discuss.google.dev/t/using-urls-and-query-parameters/115290/10 "2016-02-19T23:44:26Z")

</div>

+1 on getting it as a feature.

---

<div class="post-metadata">

**Author:** ![anonymous8](https://avatars.discourse-cdn.com/v4/letter/a/7cd45c/32.png) [@anonymous8](https://discuss.google.dev/u/anonymous8)\
**Post date:** [April 5, 2016, 12:31am UTC](https://discuss.google.dev/t/using-urls-and-query-parameters/115290/11 "2016-04-05T00:31:36Z")

</div>

@Zam Has anything in the latest releases solved this? It seems like the new links functionality might provide the answer but I haven’t had success hacking anything together yet.

---

<div class="post-metadata">

**Author:** ![Zam](https://avatars.discourse-cdn.com/v4/letter/z/e95f7d/32.png) [@Zam](https://discuss.google.dev/u/Zam)\
**Post date:** [April 5, 2016, 11:50am UTC](https://discuss.google.dev/t/using-urls-and-query-parameters/115290/12 "2016-04-05T11:50:31Z")

</div>

@Leland\_Robbins Grabbing filters is in fact possible now since `drill_fields:` is allowed on `dimensions`. We’re working on expanding the below approach to be used in `links` but for now it’s only available via `html:`

```auto
- dimension: some_field
  type: string
  sql: ${TABLE}.some_thing
  drill_fields: [field_1, field_2, field_3, or_a_drill_field_set]
  html: |
    <a href="{{ link }}">{{ value }}</a>

```

The above will use the drill fields in addition to the current filters.

---

<div class="post-metadata">

**Author:** ![anonymous8](https://avatars.discourse-cdn.com/v4/letter/a/7cd45c/32.png) [@anonymous8](https://discuss.google.dev/u/anonymous8)\
**Post date:** [April 22, 2016, 6:43pm UTC](https://discuss.google.dev/t/using-urls-and-query-parameters/115290/13 "2016-04-22T18:43:21Z")

</div>

Hey @Zam ! So currently I am using the above `{{ link }}` construction to carry filters over to a new explore, like so:

```auto
  - dimension: number_of_events_between
    label: 'Number of Events from Event 1 to Event 2'
    type: number
    sql: ${TABLE}.number_of_events
    html: |
      <a href="https://looker.counsyl.com/explore/production/timeline_sankey?timeline_sankey.source,timeline_sankey.target,claim.count{{ link }}">{{ value }}
        <img src="https://cdn1.iconfinder.com/data/icons/the-data-visualisation-catalogue-set-i/130/sankey_diagram-20.png"></a>  

```

This successfully carries over the filters from the original query (to my surprise, since I thought `{{ link }}` would just write out the full URL). However, the fields that I’ve tried to tack on here,

`timeline_sankey.source,timeline_sankey.target,claim.count`

don’t make it to the drill-down query. These fields don’t exist in the old explore, which is why I’ve tried to force them into the drill-down query here. Is there any way to successfully carry new fields or filters in combination with filters from the original query in a similar manner to what I am trying above?

---

<div class="post-metadata">

**Author:** ![Zam](https://avatars.discourse-cdn.com/v4/letter/z/e95f7d/32.png) [@Zam](https://discuss.google.dev/u/Zam)\
**Post date:** [April 29, 2016, 12:43pm UTC](https://discuss.google.dev/t/using-urls-and-query-parameters/115290/14 "2016-04-29T12:43:26Z")

</div>

@calbanese It sounds like you want to retain filters while moving to a new explore, if this is correct then it’s going to take some url munging to get there. I’d recommend returning `{{ link }}` by itself to get an idea of how the url returned looks, then from their add appropriate fields, swap out the explore, and voila!

Way easier said than done, but liquid should be able to parse and replace (similar to how Brett did in his above comment).

---

<div class="post-metadata">

**Author:** ![anonymous8](https://avatars.discourse-cdn.com/v4/letter/a/7cd45c/32.png) [@anonymous8](https://discuss.google.dev/u/anonymous8)\
**Post date:** [September 15, 2016, 2:26pm UTC](https://discuss.google.dev/t/using-urls-and-query-parameters/115290/15 "2016-09-15T14:26:17Z")

</div>

Zam:

> the url is hashed and stored in a slug

@Zam , How are the URL hashes generated? It could be useful to generate the hash ourselves (via liquid) and pass it as a slug in the html for a field (e.g. to shorten what might otherwise be a too-long URL in the case of many many filter values). Can you provide a Liquid snippet showing how to do it?

---

<div class="post-metadata">

**Author:** ![Zam](https://avatars.discourse-cdn.com/v4/letter/z/e95f7d/32.png) [@Zam](https://discuss.google.dev/u/Zam)\
**Post date:** [September 16, 2016, 8:12am UTC](https://discuss.google.dev/t/using-urls-and-query-parameters/115290/16 "2016-09-16T08:12:05Z")

</div>

@Tom\_Russell there isn’t a supported way to do it, but we may be able to come up with a workaround via the api. Will be messaging you via support@ since some of the information required in the workaround may be sensitive to your business.

---

<div class="post-metadata">

**Author:** ![anonymous8](https://avatars.discourse-cdn.com/v4/letter/a/7cd45c/32.png) [@anonymous8](https://discuss.google.dev/u/anonymous8)\
**Post date:** [October 7, 2016, 9:11pm UTC](https://discuss.google.dev/t/using-urls-and-query-parameters/115290/17 "2016-10-07T21:11:17Z")

</div>

Does `{{ link }}` work any longer? I am getting variable not found ‘link’ errors when I try to carry current explore filters through to a linked explore via urls.

---

<div class="post-metadata">

**Author:** ![sam8](https://d3byx8b92xw3lq.cloudfront.net/user_avatar/discuss.google.dev/sam8/32/21646_2.png) [@sam8](https://discuss.google.dev/u/sam8)\
**Post date:** [October 10, 2016, 7:07pm UTC](https://discuss.google.dev/t/using-urls-and-query-parameters/115290/18 "2016-10-10T19:07:52Z")

</div>

@Leland\_Robbins `{{ link }}` should still work as usual! If you’re seeing errors, would you visit [help.looker.com](http://help.looker.com) with URLs to the page that generates the error message and we can troubleshoot from there?

---

<div class="post-metadata">

**Author:** ![anonymous8](https://avatars.discourse-cdn.com/v4/letter/a/7cd45c/32.png) [@anonymous8](https://discuss.google.dev/u/anonymous8)\
**Post date:** [October 21, 2016, 9:54pm UTC](https://discuss.google.dev/t/using-urls-and-query-parameters/115290/19 "2016-10-21T21:54:53Z")

</div>

Hey team!  
It was so nice seeing everyone in person on the conference.

Can i use url parameters with API to get json formatted data?  
I only see that you can run a look by look id, in the API.

Thank you

---

<div class="post-metadata">

**Author:** ![maxcorbin](https://avatars.discourse-cdn.com/v4/letter/m/9fc348/32.png) [@maxcorbin](https://discuss.google.dev/u/maxcorbin)\
**Post date:** [October 24, 2016, 5:43am UTC](https://discuss.google.dev/t/using-urls-and-query-parameters/115290/20 "2016-10-24T05:43:12Z")

</div>

Hey there! Glad you had a good time at Join 2016 @yuriy ��

You can pass query parameters using the `run_inline_query` endpoint, which supplies several arguments such as `view`, `filters`, `limit`, etc. to change the parameters of a query on the fly through the API. However, these won’t be based on any particular Look, but rather are run against the Explore name you specify in `view`.

You can find more info about this endpoint here: [https://looker.com/docs/reference/api-and-integration/api-reference/query#run\_inline\_query](https://looker.com/docs/reference/api-and-integration/api-reference/query#run_inline_query)

[Next page](https://discuss.google.dev/t/using-urls-and-query-parameters/115290.md?page=2)
