question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

I want to be able to create default filters in my Explores

See original GitHub issue

Description: What is it?

I want to add default filters to my Explores so that when people use them, they automatically have filters applied to them.

These filters are either:

  • empty, but the field is filtered to an empty value so users are pushed to filter on that field
  • filled with one or many values

Problem: What problem does this solve?

Some datasets are really large or require specific filters to “make sense”. For example, if I wanted a Sales explore, but only for my EMEA team, I’d want to filter my sales explore to EMEA by default in their project.

Another example from a user: we are dealing with a massive amount of data partioned by date. We would like to force a filter on the date in order to force the user to apply a date. It will first avoid to have an error because you can not query a partioned table without a where condition on the date

What: Roughly, what does this look like in the product?

  • users can apply filters to Explores in their dbt projects.
  • The filters are applied on a model level (i.e. under model -->meta --> filters)
  • the filter syntax is the same as what’s used here: https://github.com/lightdash/lightdash/issues/3126
  • there are three types of filters:
    • default filters are applied to the table, but can be overridden in the UI (the same way as dashboard saved filters can be overriden, for example).
    • required filters can have their values changed, but cannot be removed from the filters list in the UI
    • sql_where filters cannot be changed and cannot be removed - these are actually hidden from the user in the UI. They’d only be visible in the compiled SQL.
  • if we need to reduce scope or break this up, we can just make default filter types to begin with, then open new issues for building the other two types
models:
  name: users
  meta:
    filters:
      - filter: ${created_at_date} # this should match the field. You can also filter on joined fields.
          sql: >= '2022-05-21' # required
          type: default # the default value for type is 'default'

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
owlascommented, Jun 6, 2022

If we want this to be fully compatible with the UI we have for filtering and interact well with dashboard filters + explore filters, the structure of the filters will need to be the same.

So instead of:

    filters:
      - filter: ${created_at_date} # this should match the field. You can also filter on joined fields.
          sql: >= '2022-05-21' # required
          type: default # the default value for type is 'default'

It would be more like:

target:
  fieldId: created_at_date  # not sure if this should be referenced with ${}
operator: "inThePast"
values: [5]
settings:
  unitOfTime: "years"
  completed: false

^ this is obviously pretty annoying to write and we could figure out a simplified structure. But we need the filters to be compatible with this layout.


type: default|required

Instead of type could we have a field isEditable: true|false or isRequired: true|false seems more intentional

0reactions
TuringLovesDeathMetalcommented, Aug 17, 2022
  1. Yes! this feels like the last piece for the three filter types: a. Default filter: can change, can be removed b. required filter: can change, but cannot be removed c. sql_where: cannot change, cannot be removed (hidden from the user)

  2. Yes, the value can change and it can be removed entirely.

  3. It cannot be removed (you have to add at least one filter on this value) - I’m not sure if the value should be able to be changed or not 🤔 I’m leaning towards “yes”

Read more comments on GitHub >

github_iconTop Results From Across the Web

Setting a filter default state - Zendesk help
Something useful in GoodData/Insights was the ability to add filters to a dashboard and set the default selections of the filter(s).
Read more >
Default Filter in Insights Dashboard - New Relic Explorers Hub
I'd like to have the filter default to only showing the production environment, but be able to easily switch between them (which filters...
Read more >
Create a default filter for a related list
Create a default filter for a related list · Navigate to the related list (example, Incidents on a problem record). · Create the...
Read more >
Create, edit, and share default filters, views, and groupings
Click the Main Menu icon · Click Interface, then click one of the following: Filters, Views, or Groupings. · Select the filter, view,...
Read more >
Creating a filter - IBM
From the menu, click Manage Filters. The Manage Filters dialog opens displaying the filters that already exist for the object type. In the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found