Metabase variables
If you do so, the best practice is to start your WHERE-block with 1 = 1, since it’s a filter-clause that’s valid and stands on its own. If you have a larger query with lots of filtering options, just chain optional clauses together. It works best when using more than one filter.Īs you can see, you’re not limited to the number of filter widgets.
#Metabase variables code
It’s invisible to the source code as long as nothing is entered into the corresponding filter widget. This widget accepts user input and directly places it at the variable’s position. They are initiated with and create a filter widget. Variables in Metabase are a great way to insert user input into existing SQL code. So what if I could enable my colleagues to change the filters themselves, making the overall process more lean, customizable, and user-friendly? Those recurring questions have their place and show that people are actually interested in that data. This can cause lots of tweaking since people are interested in more than one detail.īut most questions arise just after I complete the last query, which consumes lots of resources and my colleagues need to wait until I’m done changing the expression in the WHERE-clause every time. In most cases, building a new model will be too much effort so I write an ad hoc query in Metabase’s SQL editor. With Metabase as our BI tool, this becomes really easy and I help people to get on speed with it.īut sometimes there are questions that need a completely new table model in the reporting area of our Data Warehouse. This means we actively avoid data silos and share knowledge about our data company-wide. In our company, we go by the Data Democracy strategy.
Chris is a Data Analyst who loves to explore the possibilities of Databases and SQL.