Error when entering field filter in SQL query

Hello,

I have a fairly complex SQL query which joins numerous tables together and has a few su-selects, acting as WHERE statements.

I’ve tried to add a field filter into the query so it can be used as part of a dashboard filter. However, whenever the variable is added into the query, I get an error like below:

ERROR: invalid reference to FROM-clause entry for table “atomic.events” Hint: Perhaps you meant to reference the table alias “e”.

When I put in e. as suggest ( “e”.{{filter_name}} ) I then get an error near “AS” - which I presume is in the SQL built by the variable.

Does anyone know how to fix this error?