Is it possible to create a field filter on a where « xxxx » = « xxxxx » < {{}}

Hello,

In my database, I have displayed all postcode and I would like to create a Field filter to filter post code

but If I change 'POSTAL_CODE_CITY' by a variable, I cannot take "POSTAL_CODE_CITY" on the field " Field to map to"


--->

There is a solution to do it ?

Hi @Stekino
If you are using Field Filters, then you should not include the column and operator in the query, and the field type should be one of the specific ones like Category.
Read more about Field Filters here: https://www.metabase.com/learn/building-analytics/sql-templates/field-filters.html

I'm a novice in sql :x

How to not include the column and operator in the query and make the query and field filter working, any advice ?

Like, I would like to make 'POSTAL_CODE_CITY' as a field filter

@Stekino Please read the article again.

Go to Admin > Data Model > (database) > (table) > "POSTAL_CODE_CITY" and set the field type to "Category"
As written in the article: https://www.metabase.com/learn/sql-questions/field-filters#only-certain-fields-are-compatible-with-field-filters

You would use Field Filters like this:

where {{fieldfilter}}

As written in the article: https://www.metabase.com/learn/sql-questions/field-filters#omit-the-direct-assignment-in-the-where-clause

@flamber
thank you for your response. If I don't have access to "Admin", it couldn't be done so ?

@Stekino Then you need to contact your administrator.

@flamber,

Go to Admin > Data Model > (database) > (table) > "POSTAL_CODE_CITY" and set the field type to "Category"

"POSTAL_CODE_CITY" is not a column. This is a value of a column as described in this screenshot :

"WHERE data_type = 'POSTAL_CODE_CITY' "

So I can't get it in the administration. I am wrong ?

When we check the screenshot : We got value (Ablis - 78660 ; Adé - 65100 ; ...)

What I want to do is to insert a field filter that working with this value.

There is a way to do it ?

Or the solution may be this one ? ---> Go to Admin > Data Model > (database) > (table) > "Value" and set the field type to "something" ?

But if I don't filter the column Value, I will have a lot of value wich does not match with postal code...

@Stekino If you are not the administrator of Metabase, then contact a person who is.

You would need to change the field type in Admin > Data Model > (database) > (table) > (column).
If your case, that would be Admin > Data Model > (database) > "Provided Info" > "Data Type".

@flamber I can already filter on "Data Type" as you can see on this screenshot :

I need to filter on the "value" of the "Data Type" that I get if I filter Data Type by 'POSTAL_CODE_CITY'.

The filter need to work with the differents value of 'POSTAL_CODE_CITY' to filter by postal code.

@Stekino I don't understand. If you need to filter on another column, then use that column instead.

@flamber,

If I filter on the column "Data Type", The filter choice will be :

  • MULTIPLE_CHOICE
  • MULTIPLE_INPITS
  • ...
  • POSTAL_CODE_CITY
  • SHAREHOLDERS
  • ...
    as we can see in the last (Screenshot).

But with this query :

I get differents values as shown in the screen :

  • Ablis - 78660
  • Adé - 65100
  • Ailly - 27600
  • .....
  • Ajac - 11300

I want that my field filter choice point on this value.

@Stekino Then you have to create a different table (or View) on your database, which only contains those results.
https://github.com/metabase/metabase/issues/6820 - upvote by clicking :+1: on the first post