Fixed native SQL parameters list

Hi there, people! I’m almost sure I have already come across something on this topic, but I google it, and couldn’t find it (most likely, my poor wording).

My goal is to have a way to set a native SQL parameter which comes from a fixed list. I could try to use Field filter, but the default behaviour is not helpful, since, when using that kind of filter, Metabase does not simply exposed the value retrived from the database as a parameter, generates something like table.column IN ('values_from_db') - in other words, this won’t work.

Is there any workaround for this?

My suggestion here for metabase devs would be that, instead of generating the entire query chunk referent to the Field filter parameter, metabase would only generate the IN ('value', ..., 'value') bit, so the user can define what to do with those values in his query.

@lucas.lima

Couldn’t you just do something like this?:

WHERE [[filter_text_string]] IN (SELECT `column` FROM `table`)

Or maybe I’m completely misunderstanding your question :wink:

Err… I’m not making myself quite clear.

What is good about Field filter parameters is that they provide a specific set of possible choices to the user. That is what I’m trying to achive, but I don’t have the desired choices on a table - I could create it, but that would generate a dummy table on my Data Warehouse.

@lucas.lima
Okay, maybe I just don’t understand the use-case. You have to outweigh adding such functionality to Metabase also creates more complexity and adds another option for the users.
You should create an example and open an issue, where you ask for this feature and see if the team considers it.

Yeah, I know that is a new feature, and, while useful, is not a "must have". That is why I came more for a workaround than for a feat suggestion.

A simple use case would be like this. Say we have a table with a single column, and there is a suffix:
image

I want my user to be able to select entries with suffix_1. It is alright if I add a text filter, and use some "LIKE {{text_filter}}" SQL clause, but I want my user to see the possible suffixes, rather than typing them. So, I want a list containing suffix_1, suffix_2, ..., suffix_5, so my user knows what are the possible choices. Is that a bit more clear now?

While I can’t offer you a native or SQL workaround, limiting the choices of your example filter based on another filter might work very well. Your users could select from a filter featuring suffix_1, 2, 3, etc. and that in turn would limit your example filter to only the suffix chosen. That has been proposed and mentioned numerous times in this forum (search on “filter” and “cascading”, “limiting”, “dependent”, “linked”, etc.).

Sign in to GitHub to upvote the proposal if you feel it would benefit your use-case:
Limit the number of options displayed in a filter based on the selection of another filter (GitHub Issue #5540)

1 Like