At least one required for multiple filters

Hi,

is there a way to have a question/dashboard with multiple filter but at least one filter must be filled?

I have a question with multiple filters, each filter can be filled separately to narrow down the date. When no filter is set, the result is very large. There is an option to make each filter required individually but then you have to fill out all required filters. What I’d like to have is for the user to fill out at least one filter.

Maybe there is a workaround with some clever trick with optional SQL parameters but I coulnd’t find a way to make this work.

Cheers,
Markus

Hi @markus
Post your query, it makes it easier to understand and help.

Database is postgres, a simplified query would be:

SELECT *
FROM product
WHERE true
[[AND {{product_id}}]]
[[AND {{product_name}}]]
[[AND (product.name ilike '%' || {{product_text}} || '%' OR product.description ilike '%' || {{product_text}} || '%')]]

I’d like the users to be able to fill out any one of the three filters (or a combination of them).

My problem is that if none of the three filters are filled, the result is very large and puts a strain on the database. If any filter is filled, the query is OK.

If I mark the filters as “Required?”, the user has to fill all of the filters.

@markus Uhh, yeah, when you’re playing with Field Filters, then you don’t have the same level of control.

So you can only do complex default value with a single optional variable, when it’s Field Filters.
It might be possible to do something hacky with sub-selects and such, but I’ll leave that up to you to play with.

While it was never officially supported, it used to be supported until 0.33.5, where a big rewrite of the parameters was done to fix many other problems. Have a look at this issue:
https://github.com/metabase/metabase/issues/11313 - upvote by clicking :+1: on the first post

@flamber Thanks for the fast reply.

Yes, that’s a pity. I wouldn’t even need complex default values, it just shouldn’t run the query if no filter is filled.

Maybe the easiest workaround is to just set a limit on the number of rows. This’ll avoid loading all rows when no filter is selected and still return relevant rows with a filter.