Show all data when a filter is not in use + Use arrays in queries

I was going through this article, but I noticed that there was a case that probably some people need help with, and is when you have a multiselect but want to show all data if no value is selected.

You can achieve this fairly easy, here is an example:

SELECT * FROM "location"
JOIN leads ON leads_test."Location ID" = "location"."location_id"
WHERE
  ({{source_select.value == 0}}) -- This worked for me, not .length, but .value
  OR (leads_test."Source" = ANY ({{ source_select.value }})) -- Here you replace it for your multiselect

I hope that this helps in case you are smashing your head against the table :face_with_spiral_eyes:

3 Likes

Thank you! I was following that same article to get my multiselect field to work both when values and no values are selected. I had tried using .length to check the array but it was not working.

This solution worked for me. Thanks for sharing it!

1 Like