Is it possible to use Field filter in select command?

Hi guys, how can I use a fieldfilter into this example below:

SELECT Count(*) AS 'Total Quantity',Company
  FROM [SQLDB].[dbo].[Orders]
  WHERE MONTH(DateCreated) = {{month}}
	AND YEAR(DateCreated) = {{year}}
	AND Company <> ''
	AND Company LIKE 'STORE%'
   [[ AND OrderStatus = {{OrderStatus}} ]]
  Group By Company
  ORDER By  Count(*) DESC;

But I need to type Shipped into variable to works, I need to use FieldFilter I tried to change the Variable type Text to FieldFilter and I selected OrderStatus field into Orders Table (now we can select Shipped) but If I change to FieldFilter I receive this error after query exec:
"Incorrect syntax near '='."

EDIT I guess I got it .. is it correct? I need to remove Field = from the query?

SELECT Count(*),Company
  FROM [SQLDB].[dbo].[Orders]
  WHERE MONTH(DateCreated) = {{month}}
	AND YEAR(DateCreated) = {{year}}
	AND Company <> ''
	AND Company LIKE 'STORE%'
   [[ AND {{Orderstatus}} ]]
  Group By Company
  ORDER By  Count(*) DESC;

Hi @lucas.dj
Yes, correct. I would recommend that you read this entire article, but specifically https://www.metabase.com/learn/sql-questions/field-filters#field-filter-gotchas

1 Like