How do I apply one filter to multiple fields?

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
    56412d92-52fa-4b69-9810-9ef1dafd6a89.png
  3. Done! Now using the filter will apply the filter value to “Brand” in one tile and “Name” in the other. 
    64c22e85-a28d-4fec-aa03-39935d863f10.png

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}
    c2d0d99d-2f04-4f16-87b9-33a58f64a8cb.png
  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') )
    b0ce0736-c18f-4996-82b5-cfbda0fb7a41.png
Comments
Rahul_Chandran
New Member

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

Version history
Last update:
‎08-16-2021 03:23 PM
Updated by: