how to create a custom filter in lookml?

I have a single column called "field" and in that column it can be called "A" or "B" 

I want to have a single select filter radio button on looker with 3 options ("A", "B", "A & B") 

how can I create this kind of a custom filter? 

Solved Solved
0 3 2,036
1 ACCEPTED SOLUTION

First step is going to be creating a parameter that has the filter values that you'll want to appear in the radio button:

  parameter: gender_filter {
    type: unquoted
    allowed_value: {
      label: "Male"
      value: "male"
    }
    allowed_value: {
      label: "Female"
      value: "female"
    }
    allowed_value: {
      label: "Male or Female"
      value: "maleorfemale"
    }
    default_value: "Male"
  }

 Next step is to create a yesno dimension to help apply the parameter to whatever dimension you're trying to filter:

  dimension: gender_display {
    type: yesno
    sql: {% if gender_filter._parameter_value == "male" %} ${gender} = "Male"
      {% elsif gender_filter._parameter_value == "female" %} ${gender} = "Female"
      {% else %} ${gender} = "Male" or ${gender} = "Female"
      {% endif %} ;;
  }

 Then you can setup your dashboard to use these fields - use the yesno filter as your filter in the looks on your dashboard and set the value to "Yes" so that the values are filtered when users change the dashboard filter. 

Screenshot 2024-08-20 at 11.23.14 AM.png

 Configure your dashboard filter using the parameter you created with your three options: 

Screenshot 2024-08-20 at 11.23.55 AM.png

Screenshot 2024-08-20 at 11.24.13 AM.png

View solution in original post

3 REPLIES 3
Top Labels in this Space
Top Solution Authors