How to use array variable type in SQL question

I noticed the SQL editor template variables only have four type: text,number,date and fieild filter

I want to use array type to search,and I try it like this:

and it is not work, seem like it can not recognized as an array

so how can I use array variable in SQL template variables? thanks:sob:

Hi @jiaxing
You would have to do casting in your query. When you select Text, then Metabase sends a string.
https://www.metabase.com/docs/latest/users-guide/13-sql-parameters.html

yes!the filter type can choose multiple value like a array. but how can I let url params to replace filter type value?


I try it like this
http://10.50.125.141:30033/public/dashboard/040f35e0-b3e7-4bd6-a008-833abb479175?lastStartTime=[value1,value2,value2]
and this
http://10.50.125.141:30033/public/dashboard/040f35e0-b3e7-4bd6-a008-833abb479175?lastStartTime=value1,value2,value2
it both not work.
please and thanks

@jiaxing You are using Field Filters, which works differently than the other filter types. See the documentation.
https://www.metabase.com/learn/sql-questions/field-filters

Thanks for your patience! but there a anthor question :sweat_smile:
then I use URL params at add new question page, it`s work. but at dashboard page, it is not work.
please forget about the chinese words :joy: and sorry about my english.
first I create organizations variable on url, and set it 430112, you can see the table
image
then I change the variable, set it 430100, and you can see the table changed!
image

then I add the question to a dashboard, like this
image
because the organizations variable default value is 430112, the table is same like first img

then I add url params like this
http://10.50.125.141:30033/dashboard/1?organizations=430100
it should become like the second img, but it not change,

image

so I check the network log, the page have url params
image

but the card query do not have url params

image

thank you!!!

@jiaxing There's no filter on the dashboard:
https://www.metabase.com/docs/latest/users-guide/08-dashboard-filters.html

It took me way too long to work out & the docs make no mention of how to handle it at all, so hopefully this helps someone else:

I want to filter by a list of UUIDs (tho it’s the same for any list of strings).

I wanted to be able to paste a list like 00000000-0000-0000-0000-000000000000, 00000000-0000-0000-0000-000000000001 into the variable field (but this also supports space-delimited lists).

select id
from my_table
where true
	and id in (
		select regexp_split_to_table({{ids}}, '[, ]+')::uuid
	)
;

{{ids}} is the variable, set it to type “Text”

regexp_split_to_table converts the quoted string metabase passes (which cannot be changed :downcast_face_with_sweat:) into records, based on the delimiter.

'[, ]+' as the delimiter means split the string on 1 or more commas or spaces

::uuid is casting the string to UUID; you may need to remove it or cast to something else.

I couldn’t get any other = any( {{ids}} )or in ( {{ids}} )style incantation to work.