[SOLVED] Using optionnal Field Filters

Hello guys,

I am struggling with field filters. I am facing 3 issues (in their description, I refer to the code at the bottom of my post):

  1. With “Source” as a text input the filter is working if I input “FilterValue1” but with a field filter type, if I pick “FilterValue1”, there are no results. I am assuming it is a data type issue.
  2. Is it possible to select multiple “Source” at once when using a field filter ?
  3. How can I make this filter optional meaning, if “Source” is a filed filter, how can I make sure that if the end user does not pick any value, it won’t filter. I haven’t been able to do so using optional clauses with field filters.

My code

SELECT count(*) AS "count"
FROM "public"."events"
[[WHERE "public"."events"."source" in ({{Source}})]];

I hope you can help me. Even if you can’t, thank you for reading this post.

Yacine

Metabase does some magic on the FieldFilters.

SELECT count(*) AS "count"
FROM "public"."events"
WHERE {{Source}};
2 Likes

Haha, I did not expect that. Thank you, problemS solved.