Using varchar types in field filters

I have a simple query that has a field filter for a company name, so the query in postgres/dbeaver is:

select some stuff
from company
where = ‘My Company Name’

I change the where clause to:
where = {{company_name}}
and choose field filter from the variables list, find the column in the company table, and i notice that the filter widget type is “Category”, and run the query in metabase. The filter correctly pulls the company names, but the query will not run. I assume this is because the where clause has no quotes.

So I modify the where clause to:
where = ‘{{company_name}}’
but that also does not work

so I try:
where = “{{company_name}}” still no luck.

I notice the filter widget type is “Category”, but i have no idea what this means - is this a text field, varchar, integer, or something else? I check the data model, and the column there is identified as “Entity Name”, which I assume is something like a varchar (or character varying) field. Going back to the filter widget type, maybe i need to change that to “Entity Name”, but the only options are either “Category” or “None”.

How do I get text from the field filter into the where clause with quotes such that the query will run? Even better, how do I use a SQL query as a field filter so that i can filter more efficiently on the PK of that table, but present to the user the company name so that the user would see a list of company names, but the field filter will pass the pk id associated with that compan name to the actual query?

Thank you!

Hi @blanehart
That’s not how Field Filters works - have a look here:

1 Like

Thank you - I was able to figure it out from the blog link.