Why isn't my liquid variable passing values into my URL filter correctly?

Knowledge Drop

Last Tested: Jan 29, 2020

There are two main reasons that this happens:

  1. The values are not url-encoded (can be solved by using {{value | url_encode}} )
  2. The values have special matches (advanced) filter expression characters in them. In some cases this can be fixed by using filterable_value instead of just value , but this won't work for all special characters. If you want to guarantee that the value will be passed into the filter exactly as is, you should specify "type":"=" in the filter_config url parameter. The final URL should look something like this: /dashboards/[DASHBOARD_ID]?filter_config=%7B"Filter%20Name":%5B%7B"type":"%3D","values":%5B%7B"constant":"{{ value | url_encode }}"%7D,%7B%7D%5D,"id":9%7D%5D%7D

Additional resources:

https://help.looker.com/hc/en-us/articles/360001161308-How-to-Escape-Commas-in-Filters

https://docs.looker.com/reference/liquid-variables#liquid_variable_definitions

This content is subject to limited support.                

Comments
Beto
Participant II

Hello , I’m having an issue in which I have a parameter in my URL , for the most part it works well except one the user selects the values that have an underscore in the value of the selection.

So, the parameter allows my user to have a dynamic dimension on the dashboard , that all works fine, then I have another dashboard to which I'd like to navigate to from dashboard number one. The second goal of that navigation is to also take with you all the applied filters and selections done in the parameters. To achieve that I’m using the link property on the dynamic dimension.

Parameter: 

parameter: MyParam {
    type: unquoted
    default_value: "Value1"
    allowed_value: { label: "Something" value: "Value1"}
    allowed_value: { label: "Something" value: "Value2"}
    allowed_value: { label: "Something" value: "Value_3"}
    allowed_value: { label: "Something" value: "Value4"}
    allowed_value: { label: "Something" value: "Value_5"}
    allowed_value: { label: "Something" value: "Value_6"}
}

Then I have a link:

&ParameterNameOnDashboard={% parameter MyParam %}

So, when the user selects value1 , 2 or 4 , it all works fine , the navigation occurs and it takes away the value selected. The problem arises when the user selects option 3,5 or 6. Then it doesn't work because of the “_” and the URL encoding I believe, that encoding is not being done so while the browser is expecting something like “Value%5E_5” he’s actually receiving “Value_5” and then it brakes.

I tried: 

&ParameterNameOnDashboard={% parameter MyParam | escape %}
&ParameterNameOnDashboard={% parameter MyParam | URL_ENCODE %}
&ParameterNameOnDashboard={% parameter MyParam | URL_DECODE %}

but none of those worked. Any ideas on how i can solve this one !?

Version history
Last update:
‎04-05-2021 09:09 AM
Updated by: