1

Not being a SQL expert, and discovering Metabase here, so please be kind; I'm working on a dashboard that would offer a specific filter.

For the sakes of clarity, I'll describe my simplified case.

I have some projects in my DB. Some are "active", some aren't. I would like to create a filter that provides only a selection of those "active".

Because my project settings are in a different table than the project itself, here's basically how I've tried to create this filter:

SELECT "public"."Project"."status" AS "status", "ProjectSettings"."name" AS "ProjectSettings__name"
FROM "public"."Project"
LEFT JOIN "public"."ProjectSettings" "ProjectSettings" ON "public"."Project"."id" = "ProjectSettings"."projectId"
WHERE (
   "ProjectSettings"."active" = 'ACTIVE')
   AND "ProjectSettings"."name" = {{Project}}

What I was expecting to happen here is that only the filtered active projects were made available in my filter. Without any luck so far.

Thanks for your suggestions :)

pixelboy
  • 739
  • 1
  • 12
  • 36

1 Answers1

0

I assume {{Projects}} is a collection of multiple projects. Is that correct? if so, you should use an IN clause in the criterion.

WHERE (
   "ProjectSettings"."active" = 'ACTIVE')
   AND "ProjectSettings"."name" IN {{Project}}

the listing {{Projects}} should then be in the form 'project1','project2','project3',...

Wilgin
  • 26
  • 5