Saving Native Query Questions with variables for use with dashboards

metabase_issue_variable!

So I am having trouble getting native query questions to display both in dashboards and in pulses. I get the feeling that I'm missing something obvious but I can't figure it out for the life of me. Has anyone else experienced something similar and if so, how did you get it working?

Running v0.28.5 but I'm also experiencing the same issue on v0.28.6 when running it locally. Any help would be greatly appreciated!

Thanks for building Metabase by the way! You all rock!

metabase_issue_novar

I guess I should also mention that it works perfectly as long as you don't use variables which is what has me so confused. Thanks again for your time!

Yeah, what’s happening here is that your question is getting run without your variable being given a value. I.e., in your GIF, the value of 1 that you gave it doesn’t get remembered or stored as part of the question.

So you either need to mark your variable as optional by putting double square brackets around it, like [[where ORDERS.id = {{order_id}}]], or you can mark it as Required using the toggle in the side panel and give it a default value. Check out the Optional Clauses section of this doc page for details.

If you want that variable to be filterable on a dashboard, you’ll want to use a Field Filter variable instead. Details on that are in the same doc as I linked to above.

1 Like

That did it! Thanks so much!

1 Like