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 Redirecting…, 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:
-
Is there a way to add multiple filters to a single question in Metabase?
-
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