Question

How do I apply one filter to multiple fields?

  • 17 August 2021
  • 1 reply
  • 143 views

The Use Case: 

Say you want to have a single filter apply to two separate fields (fields A and B). The end goal is to be able to update both fields with a single filter, to avoid forcing an end user to type in the same filter value into 2 filters. 

There are a few ways to achieve this! 

 

The Solution(s): 

If fields A and B appear in separate tiles on a dashboard, then the solution is simple. We can create a single dashboard filter that’s based on either field A or field B, and then update the “Tiles to Update” section of the filter settings to update the appropriate fields in each tile. For example: 

In my example case, say we want to create a single filter that applies to the following fields: “Brand” and “Name”. We’ll take the following steps: 

  1. Create a dashboard filter based on either “Brand” or “Name” (it doesn’t matter which we choose)
  2. In the “Tiles to Update” section of the filter settings, set the filter to apply to the “Brand” field in the Brands tile, and to apply to the “Name” field in the Names tile

     

  3. Done! Now using the filter will apply the filter value to “Brand” in one tile and “Name” in the other. 

     

If fields A and B appear in the same tile on a dashboard, or we’re using a Look, then we can use liquid to achieve our goal. The general idea will be to create a filter-only field, and use the sql parameter to apply the filter value to multiple fields.

Let’s use the same example as above, where we want a single filter to update the “Brand” and “Name” fields. We’ll take the following steps: 

  1. Create a filter field in the LookML
  2. Define a sql parameter within the filter (this will apply a WHERE clause to the generated query), and use liquid like the following: {% condition %} ${brand} {% endcondition %} AND {% condition %} ${name} {% endcondition %}. This applies the filter value to both ${brand} and ${name}

     

  3. Create a dashboard filter based on the new filter field, and have it apply to the filter field in the “Tiles to Update” section
  4. Done! Now the filter value the user chooses will use a where clause like the following: WHERE (((products."NAME") = 'filter_value') and ((products."BRAND") = 'filter_value') )

     

 


1 reply

This is amazing and I am sure our customers will Love it. Thanks Sarah

Reply