Field Filters error

Hello everyone,

I'm facing difficulties using the Field Filter in Metabase. My issue is that my main table does not contain the client name, so I need to perform an INNER JOIN to retrieve it from another table.

The query runs normally, and I can display client names, but when I apply the filter to select a specific client, I get the following error:

ERROR: invalid reference to FROM-clause entry for table "projects_table"
Hint: Perhaps you meant to reference the table alias "b".
Position: 1490

Has anyone encountered this issue before or knows how to fix it? Any help would be greatly appreciated! :blush:

Below is my illustrative SQL query:

SELECT
A.product_description,
B.client_name,
COUNT(*) AS total_projects,
COUNT(CASE
WHEN A.assembly_date IS NOT NULL
AND A.manufacturing_date IS NULL
AND A.stock_date IS NULL
AND A.delivery_date IS NULL
THEN 1 END) AS assembly,

COUNT(CASE 
    WHEN A.manufacturing_date IS NOT NULL 
         AND A.finishing_date IS NULL 
         AND A.stock_date IS NULL 
         AND A.delivery_date IS NULL 
    THEN 1 END) AS manufacturing,

COUNT(CASE 
    WHEN A.finishing_date IS NOT NULL 
         AND A.stock_date IS NULL 
         AND A.delivery_date IS NULL 
    THEN 1 END) AS finishing,

COUNT(CASE 
    WHEN A.stock_date IS NOT NULL 
         AND A.delivery_date IS NULL 
    THEN 1 END) AS stock,

COUNT(CASE 
    WHEN A.delivery_date IS NOT NULL 
    THEN 1 END) AS delivered,

CASE 
    WHEN COALESCE(COUNT(CASE WHEN A.delivery_date IS NOT NULL THEN 1 END), 0) = COUNT(*) 
    THEN 'Delivered'
    ELSE 'In Progress'
END AS delivery_status

FROM production_items_table AS A
INNER JOIN projects_table AS B
ON A.project_id = B.project_id
INNER JOIN clients_table AS C
ON B.client_name = C.client_name
WHERE {{client_name}}
GROUP BY A.product_description, B.client_name
ORDER BY A.product_description;
Note: The table names and fields in this query are illustrative and may differ from the actual database structure.

Any insights or suggestions would be greatly appreciated! :rocket:

if u use the join for getting the filter, u don't use a aliases for table. u can click the icon 'eye' for saw how the query is work in metabase.

Thanks for your tip, that was exactly what I needed!