Adding Multiple Filters to One Question in Metabase

Hello, everyone

I’m new to metabase and I’m currently facing the following problem. One of my customers (the team that gets the dashboard) needs a dashboard which allows them to filter three things: the date, the deadline and the motor type. My Query workds and looks like this:

SELECT _deadline._end_date AS datum, 
    _deadlinetype._name as Frist,
    akten.motorenbezeichnung as Motoren,
    COUNT(*) as Anzahl_Fristen
FROM akten
LEFT JOIN _deadline ON _deadline._akte_oid =akten.oid
LEFT JOIN _deadlinetype ON _deadlinetype._oid = _deadline._type_oid
WHERE testakte !="Ja"
    AND _deadline._closed_at IS NULL
    AND _deadline._end_date between current_date AND ADDDATE(current_date, INTERVAL 30 day)
    [[AND {{Fristart}}]]
    [[AND {{motorenbezeichnung}}]]
    
GROUP BY _deadline._end_date, _deadlinetype._name, akten.motorenbezeichnung

However, whenever I try to add the filters to the Question, I only see one option to add one filter:

So at this point, I’d like to ask the following: Am I missing something or isn’t there a way to add multiple filters to one question? (Please, notice that the native Query does allows for two filters).

By reading the documentation, I tried to think of a work around, which is basically referencing to an unaggregated version of the query above as a sub-query and trying to aggregate this on the outer-query.

In other words, the Sub-Query would look like this:

SELECT _deadline._end_date AS datum, 
    _deadlinetype._name as Frist,
    akten.motorenbezeichnung as Motoren
FROM akten
LEFT JOIN _deadline ON _deadline._akte_oid =akten.oid
LEFT JOIN _deadlinetype ON _deadlinetype._oid = _deadline._type_oid
WHERE testakte !="Ja"
    AND _deadline._closed_at IS NULL
    AND _deadline._end_date between current_date AND ADDDATE(current_date, INTERVAL 30 day)
    [[AND {{Fristart}}]]
    [[AND {{motorenbezeichnung}}]]

And I would reference this subquery doing the following:

SELECT datum, Frist, Motoren, COUNT(*)
FROM {{#1793}}
GROUP BY datum, Frist, Motoren

Where {{#1793}} is the number of the query in my system.

However, I get this error message: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ‘’ at line 11

This bugs me a bit, because something similar is writen in the documentation https://www.metabase.com/docs/latest/users-guide/13-sql-parameters.html#using-an-existing-question-as-a-sub-query, but even the exact query displayed does not seem to work for me (COUNT(*) FROM [reference to question]), since I get the same error message.

And even the error message is weird, because I don’t even get to line 13 in my query, but error reports to that line.

Anyway, I’d appreciate any help answering the following questions:

  1. Is there a way to add multiple filters to a single question in Metabase?

  2. Why can’t I reference to a previous query?

I’m using Metabase version 0.36.5.1 and my Databank is MariaDB.

Thanks in advance

Hi @celioxf

  1. You need to create multiple dashboard filters, and link each of those to the cards:
    https://www.metabase.com/docs/latest/users-guide/08-dashboard-filters.html
  2. This is similar to Saved Questions, which doesn’t expose the nested filters either.
    https://github.com/metabase/metabase/issues/6449 - upvote by clicking :+1: on the first post

Hey,@flamber. Thanks for replying. I’m not sure I fully understand your suggestion though.

Even though I’ve added multiple filters to the dashboard, I only see the option to add one of them to the question.

@celioxf I don’t think I understand. When you edit a dashboard filter, then you can link that specific filter to a card. And then you do that for each dashboard filter you want to apply to the cards.
Also, latest release is 0.36.6

Hey, @flamber.

My bad! I understook what you meant now! Thanks for replying quickly and taking the time to do it!