I’m making heavy use of query parameters and query filters with redash. One issue I’m stuck on though is … how to make the parameter or filter OPTIONAL.

When working with some data sets, I want to display the entire results … or optionally allow the entire dataset to be reduced by specific criteria.

However, as soon as I introduce the query parameter or a query filter … the dataset reduction is forced. I end up forking the original query so that I have two that are identical except for the query parameter or query filter portion.

For example

All customers, including type:

SELECT 
  customer.id,
  customer.name,
  customer.type
FROM customers

All customers, but with a query parameter … the parameter forces a data set reduction … and it has to be run over and over each time the you want to view differently:

SELECT 
  customers.id,
  customers.name,
  customers.type
FROM customers
WHERE customers.type = '{{ customer_type }}'

All customers, but with a query filter … the filter is automatically set and can’t be removed to display the entire original dataset.

SELECT 
  customers.id,
  customers.name,
  customers.type AS "type::filter"
FROM customers

All customers, but with a query multi-filter … this actually works in this use case … however … it’s super clunky for other uses cases …

SELECT 
  customers.id,
  customers.name,
  customers.type AS "type::multi-filter"
FROM customers

All users by customers, but with a query multi-filter … this works, but an example of how it’s crazy counter-intuitive and clunky:

SELECT 
  users.name,
  customers.name AS "type::multi-filter",
FROM users
LEFT JOIN customers ON users.customers.id = customers.id

… If you have say 250 customers, you have now the option of selecting from none, all, or any variation of 250 separate tags, when all I was hoping for was a dropdown that would let me select all customers, or one the the 250 customers …

Is there anyway to do what I’m asking?

Until “optional parameters” are supported in code, you can use this workaround.

1 Like