Field Filters Work Correctly in Dashboard, Do Not Appear in Question Editor

Currently running Metabase version 0.37.0.2

I have a question with several field filter variables. Their types have been set in the Data Model, and link correctly when implemented into a dashboard.

However when looking at the Question directly, only some of the field filters appear on the top of the screen.

I would like to use Public Sharing to directly share this question, rather than place it in a dashboard. However it only provides the ability to filter by the three filters shown, rather than all of the filters present in the query. I’ve had other questions where this happens, and it makes it rather inconvenient to share or debug a Question.

Please advise.

Hi @nick-sbp
Each of those variables is a Field Filter?
I haven’t seen this before unless “Filter widget type” was set to “None”.
Please check the browser developer console for errors.

Yes, each of them is a field filter. Although I’ve noticed some strange behavior with them. The Filter Widget type on three of them keeps resetting itself, although the correct type is available in the dropdown and selected within the datamodel.

This is the only error message displayed in the console:

Refused to connect to 'https://www.google-analytics.com/j/collect?v=1&_v=j87&a=807537344&t=event&_…0817802-1&_gid=2062261191.1605544152&_r=1&_slc=1&cd1=v0.37.0.2&z=114923642' because it violates the following Content Security Policy directive: "connect-src 'self' metabase.us10.list-manage.com ".
wd	@	analytics.js:37
pe	@	analytics.js:36
Sa	@	analytics.js:41
Ha.D	@	analytics.js:39
pc.send	@	analytics.js:71
X.b.<computed>	@	analytics.js:51
Z.v	@	analytics.js:85
Z.D	@	analytics.js:84
N	@	analytics.js:85
trackEvent	@	app-main.bundle.js?7…dac9c1025c4c0ef41:5
(anonymous)	@	app-main.bundle.js?7…dac9c1025c4c0ef41:5
l	@	vendor.bundle.js?7c4dac9…:98
(anonymous)	@	vendor.bundle.js?7c4dac9…:98
(anonymous)	@	vendor.bundle.js?7c4dac9…:98
r	@	app-main.bundle.js?7…dac9c1025c4c0ef41:5
(anonymous)	@	app-main.bundle.js?7…dac9c1025c4c0ef41:5

@nick-sbp
Post “Diagnostic Info” from Admin > Troubleshooting, and which database type you’re querying.

I have never heard of that before. I’m not totally sure what’s going on, but make sure that no-one else is editing the question.

What exactly do you mean by “keeps resetting itself”? What does it change from and to?
What is the Field Type in Data Model?

The error is because you probably got an adblocker in your browser.

Here is the Diagnostic Info:

{
  "browser-info": {
    "language": "en-US",
    "platform": "Win32",
    "userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4315.4 Safari/537.36",
    "vendor": "Google Inc."
  },
  "system-info": {
    "file.encoding": "UTF-8",
    "java.runtime.name": "OpenJDK Runtime Environment",
    "java.runtime.version": "11.0.9+11-Ubuntu-0ubuntu1.20.04",
    "java.vendor": "Ubuntu",
    "java.vendor.url": "https://ubuntu.com/",
    "java.version": "11.0.9",
    "java.vm.name": "OpenJDK 64-Bit Server VM",
    "java.vm.version": "11.0.9+11-Ubuntu-0ubuntu1.20.04",
    "os.name": "Linux",
    "os.version": "4.4.0-19041-Microsoft",
    "user.language": "en",
    "user.timezone": "America/New_York"
  },
  "metabase-info": {
    "databases": [
      "h2",
      "mysql",
      "sqlserver"
    ],
    "hosting-env": "unknown",
    "application-database": "h2",
    "application-database-details": {
      "database": {
        "name": "H2",
        "version": "1.4.197 (2018-03-18)"
      },
      "jdbc-driver": {
        "name": "H2 JDBC Driver",
        "version": "1.4.197 (2018-03-18)"
      }
    },
    "run-mode": "prod",
    "version": {
      "date": "2020-10-26",
      "tag": "v0.37.0.2",
      "branch": "release-x.37.x",
      "hash": "ba7be09"
    },
    "settings": {
      "report-timezone": null
    }
  }
}

For instance on the variable ‘client’, I’d like the Filter Widget Type to be ‘Category’. It is set as such in the datamodel. However even after saving the question, it will reset itself to ‘None’. Although I’m able to hook into it when adding filters within a Dashboard.

@nick-sbp
I don’t know what is happening. I have never heard about this before. Please check with a browser without any extensions.

Does this happen with all questions or only this question?
Can you reproduce with a new question using the Sample Dataset:
SELECT COUNT(*) FROM PRODUCTS WHERE {{Category}}

You should migrate away from H2, if you are using Metabase in production:
https://www.metabase.com/docs/latest/operations-guide/migrating-from-h2.html

While it most likely won’t fix anything related to this, the latest release is 0.37.2

So I’ve found the solution. However as far as I’m aware this is not something that was mentioned in the docs, and may be considered a bug or user error.

In order for it to function correctly the variable name must match the actual column name. In the example I gave, the three working variables had names corresponding to their actual column name. Whereas with the others, the original creator of the table gave them godawful names, and so I named the variable something that represented it better semantically.

With the column names fixed it works correctly. For whatever reason this breaks the field filters in the Question editor, but the Dashboard editor seems invariant to the variable names when hooking into them.

There was another strange behavior with the broken column names I’d like to add though. For the broken columns, whenever I would edit the variable in the editor. It wouldn’t prompt me to save. As if I had made no changes to the variable.

Anyways @flamber I really appreciate the level of responsiveness, enjoy your day

@nick-sbp I cannot reproduce that. You can call the variable anything (like {{something}}) and reference a column called category. And then you can give the variable a display name of My Categories.

You can try with Sample Dataset:

SELECT COUNT(*) FROM PRODUCTS
WHERE 1=1
[[AND {{something}}]]
[[AND {{vendor}}]]

I think there has been something wrong with the initial variables (the actual reference code it makes behind the scenes), but there should have been errors in the browser console and/or log.

@flamber It seems you’re right, the names weren’t the issue.

Good news though, I did figure out how to reproduce the issue. At least on my end.

Have a column set to category in your Datamodel
Create a Question with a field filter set to that column
Save said Question

The Question will now be functioning correctly.

Go into the variable editor
Set ‘Filter Widget Type’ to ‘None’
Set ‘Filter Widget Type’ to ‘Category’
Save Question

It will now exhibit the broken functionality I talked about before. If relevant at all, the db in question is an SQL server.

1 Like

@nick-sbp Nice work detective!
https://github.com/metabase/metabase/issues/13825 - upvote by clicking :+1: on the first post