Question

Filter Expressions in URL Query Parameters

  • 28 October 2017
  • 4 replies
  • 291 views

Howdy,


I am trying to add a hard-coded filter to the html parameter I have written for a dimension. Currently, I have the following (to allow me to drill to a look via the dimension and apply a filter to said look with the dimension’s value):


dimension: dimension_1 {
type: string
sql: ${TABLE}.dimension_1
html: <a href="/looks/260?f[view_1.dimension_1]={{ value }}">{{ value }}</a> ;;
}

I would like to add another hard-coded filter (e.g. is greater than or equal to 10) on a measure (type count) from another view to this html parameter. I was thinking it’d be something like this:


html: <a href="/looks/260?f[view_1.dimension_1]={{ value }}&f[view_2.measure_1]>=10">{{ value }}</a> ;;

However, this does not work. Neither does this:


html: <a href="/looks/260?f[view_1.dimension_1]={{ value }}&f[view_2.measure_1]=is+greater+than+or+equal+to+10">{{ value }}</a> ;;

Any and all help is much appreciated! Thanks!


4 replies

Howdy @camille.vernon,


You’re definitely on the right track, you just needed the url friendly version of >=



html: <a href="/looks/260?f[view_1.dimension_1]={{ value }}&f[view_2.measure_1]=%3E%3D10">{{ value }}</a> ;;



A great way to work this out is to make the desired filters in an explore in Looker and then click the cog ⚙ in the upper right corner and select share, then look at the long url to see what it looks like. For example, if you have a filter on view_2.measure_1 >= 10 you can then look at the long url and find f[view_2.measure_1]= in the url and see what Looker has generated for the filter criteria, in this case it will be f[view_2.measure_1]=%3E%3D10.


If you have further questions, let us know!

Thanks @jeremy.eckman ! Looks like I need to brush up on my URL-encoding. Great suggestion on getting this info directly from Looker.

Great tip @jeremy.eckman  !

 

Another thing that I got stuck on was using greater than .. 

so if I want to show only results with values (aka > 0)

&f[measure]>0 doesn’t work 

if needs to “equal” > 0 

so $f[measure]=>0 (or in proper encoding:  $f[measure]=%3E0

Userlevel 1

Howdy @camille.vernon,

 

You’re definitely on the right track, you just needed the url friendly version of >=

 

 

 

html: <a href="/looks/260?f[view_1.dimension_1]={{ value }}&f[view_2.measure_1]=%3E%3D10">{{ value }}</a> ;;

 

 

A great way to work this out is to make the desired filters in an explore in Looker and then click the cog ⚙ in the upper right corner and select share, then look at the long url to see what it looks like. For example, if you have a filter on view_2.measure_1 >= 10 you can then look at the long url and find f[view_2.measure_1]= in the url and see what Looker has generated for the filter criteria, in this case it will be f[view_2.measure_1]=%3E%3D10.

 

 

If you have further questions, let us know!

 

Hi,

I know this is an old thread , but is it possible to use the same when the value needs to be encoded in the url dynamically

Reply