Dashboard filter for boolean type field

I made a dashboard and add a filter on boolean field (named ‘is_day’). When I typed True or TRUE or true in this field, it was shown this error in the original question:

“ERROR: operator does not exist: boolean = character varying Hint: No operator matches the given name and argument type(s). You might need to add explicit type casts. Position: 713”

I saw ‘view the sql’ and find this converting from my field filter:
is_day = ‘TRUE’

I explored in column’s type setting and didn’t find type for boolean.

Metabase version: 0.36.2

Hi @h03ein
Please post “Diagnostic Info” from Admin > Troubleshooting, and which database you’re querying.
What is the Field Type in Admin > Data Model > (database) > (table)?
Which type of question is it - GUI or SQL? If SQL, which type of filter variable is it?
Which type of dashboard filter is it?
Latest release is 0.37.0.2

Hey flamber,

I do have the same issue, maybe we can find a Solution for People searching in google "Metabase boolean filter"
-> Because searching for "Metabase boolean filter" leads directly to this topic :stuck_out_tongue:

Metabase Version: v0.41.0
Field Type: Category
Type of Question: Native Question (SQL Query)
Type of Dasboard Filter: Categorie

Variable Type = Field Filter

I do get this Error with Variable type = Text:

image

And this Error with Variable type = Field Filter:

image

When I use Field Filter, he gets it correct, that there is "true" and "false" as possible value.

Text and Number Filters working good in the same Question, it is only about boolean Filters.

Thx

@Thomas165 You cannot use Field Filter like that, since Metabase has to control it. Have a read here: https://www.metabase.com/learn/sql-questions/field-filters.html

I have worked around the lack of a boolean field by using a text field instead.

  1. Create a new field named is_day with the Filter widget label equal to Is Day? (0 = no, 1 = yes)
  2. Add the following condition to your where clause:
     [[and IF(is_day = 'day', '1', '0') = {{is_day}}]]
    

You should now be able to add 1 for days and 0 for non-days.


Metabase v0.48.6