Reference View in SQL Runner

Hey all

I have a use case where we have a number of views, constructed from SQL queries. These queries require a hard-coded condition in a couple of different places in the query (so a few dozen places where this one condition is duplicated across the project). The condition changes frequently, and at the moment there’s a bit of overhead to keep it current.

What I would like to do is have a singular place where I can go to update this value, and have all of my queries reference that place, like in a view or something along those lines, where my query can just be run against the model and get the value as a subquery. However, I haven’t been able to work out how this can be done; setting up the condition as a view/explore and then referencing it in a query run against the model doesn’t seem to work.

Anyone got any advice to get that working, or know of any other feature that might do the job? Any help is appreciated.

Don’t know if it’s possible use a constant in the sql statement but have you tried?

I’ve tried, but either I’m not doing it properly, or it doesn’t work (unknown escape sequence). I’m not sure it would fit this case anyway, since the condition is an IN, with a list of values that change, and my understanding on constants is that they’re strings only? I may be wrong though :sweat_smile: Thank you though!