New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Field filter from nested query #6449
Comments
It would be very useful to propagate variables from the originating question to the derived question. |
Same issue. |
I am trying to create a cumulative sum view of a filterable custom sql query but cannot pass the variables through on the cumulative sum view via the dashboard. This is a must have for us, unless someone knows another way to do a cumulative sum view in SQL. |
Variables are currently not available to parent questions, so it would require allowing pass-thru of those, which would involve some permission levels too. It's slightly more complicated than what it sounds like. |
This comment was marked as outdated.
This comment was marked as outdated.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
@rouanes: I am using Postgres, which DB do you have? |
This comment was marked as outdated.
This comment was marked as outdated.
@rouanes: I'm afraid that I cannot help without your specific query. The FROM clause is not mandatory in Postgres, so there's another problem somewhere. Here's a working example as a reference: -- Original question
-- It will receive the variables from the derived question.
-- I saved it as quenstion_id = 123 and called it something like "power with arguments"
SELECT power({{base}}, {{exponent}}) AS "base raised to the power of exponent" Base and exponent are defined as "Number" variables and are "required" with 2 as default values (to keep the showcase sane). -- Derived question
-- Contains variables which get pushed down to the original question, simply by defining them.
-- The variables here have no other purpose in the derived questions.
WITH
subquery_args AS (
-- use the same variable names that you have in the original question.
SELECT 1 WHERE {{base}} IS NULL AND {{exponent}} IS NULL
)
, power_with_args AS {{#123}} -- this is the original question from above!
SELECT *
FROM power_with_args Make sure to define the variables with the same types as the variables in the original question. |
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
I've coded a solution, that pulls, merges and pushes questions from a local file repository. That way you can work around this issue in an elegant way. |
This comment was marked as outdated.
This comment was marked as outdated.
Providing manual dropdown options might be a temporary user experience patch for this issue. |
Is this ever happening? Definitely a big miss currently when trying to avoid duplication / work with base queries in large datasets. |
Unfortunately, the workaround I had (see below) stopped working with Metabase 0.43. It works until 0.42.6. This is currently limiting my abilities to upgrade Metabase. Before upgrading I would have to modify several hundred saved questions and introduce a lot of duplicate SQL in each query.
|
Same, except I already upgraded and just noticed that it's broken. |
Stumbled upon this problem again today and I can confirm the workaround of re-using the variable in the parent query does not work in latest metabase version (v0.48.6) |
Looks like it's been 7 years since this was first reported. For my use case this makes Metabase basically unusable. Is it likely this will be worked on? |
I have created custom SQL with Field filter and add the question to dashboard. I can add category filter and choose the field
And then I create another question based on previous question this is pie chart. And I add the question to the dashboard but I can not use variable from previous question for filtering
Thank you
⬇️ Please click the 👍 reaction instead of leaving a
+1
orupdate?
commentThe text was updated successfully, but these errors were encountered: