How to make filter field choose only on subset of table

Hi guys!

I am using a field field in one question.
This gives my users the ability to filter their chart based on a product name.

However, when looking for a name, they can choose between the entire product table and not just the products they own, thus generating both some confusion and insecurity.

Can you help me understand how I would have this field filter for product name only display the products the organization owns ?

Herebelow is my sql.
I'd like product.name widget to only suggest product names where product.owner_id is equal to the variable organization.id

SELECT date_trunc('minute', "Order Line"."updated_at") AS "Order Line__updated_at", "Supplier"."name" AS "Supplier__name", "Order Line"."id" AS "Order Line__id", sum("public"."supplying_item"."amount_per_thousand") AS "sum"
FROM "public"."supplying_item"
LEFT JOIN "public"."supplier" "Supplier" ON "public"."supplying_item"."supplier_id" = "Supplier"."id" LEFT JOIN "public"."product" "Product" ON "public"."supplying_item"."product_id" = "Product"."id" LEFT JOIN "public"."order_line" "Order Line" ON "public"."supplying_item"."id" = "Order Line"."supplying_item_id" LEFT JOIN "public"."product" "Product_2" ON "Product"."original_product_id" = "Product_2"."id"
WHERE ("Supplier"."owner_id" = {{organization.id}}::uuid
   AND "Product_2"."recipe" = FALSE AND "Product_2"."name" IN (SELECT "name" FROM "public"."product" WHERE {{product.name}}))
GROUP BY date_trunc('minute', "Order Line"."updated_at"), "Supplier"."name", "Order Line"."id"
ORDER BY date_trunc('minute', "Order Line"."updated_at") ASC, "Supplier"."name" ASC, "Order Line"."id" ASC

Thanks a lot

Hi @svassaux
You can use Linked Filters: https://www.metabase.com/learn/dashboards/linking-filters
But then both variables have to be using Field Filters otherwise Linked Filters won't take effect: https://github.com/metabase/metabase/issues/14595

1 Like

nice, it works with linked filters.