Add additional part to a query from Query Library

Query Library is a great feature to re-use queries, but sometimes dashboards may use one dataset but have different filters which I need to add as additional where clauses. Now it is impossible - I tried to add a common {{ where }} tag hoping to fill it with corresponding conditions but failed.
Adding a feature that builds different queries based on one ancestor and transforms it regarding special needs might be a great help.
Thanks in advance.

Hey Mikhail, welcome to the Retool community—thanks for posting.

Have you tried using the variables feature for your shared queries? Would be interested to know more about where that works/doesn't work for your use case.


Hi Ryan,
thank you for your help but variable feature may help in case you have one condition with different values. It doesn't help me to define different field lists, where clauses or joins for specific needs.

Do you have an example of a query that's representative of this case? (Multiple conditionals, etc)

Let's imagine a situation when I have one query but two pages where a customer can set up different filters and display filtered data. The query may be quite complex and I don't want to synchronize two exact the same queries except filter conditions so it might be good to write something like that:
select * from table
{{filter_conditions}} -- these conditions I want to build with JS based on UI options selected.