Hi everyone,
I'm facing a persistent issue with a dashboard filter connected to a MongoDB database, and I hope someone can help.
My Environment:
- Metabase Version:
[ v0.53.8.4]
- Database: MongoDB
The Core Problem (Two-fold): I have a dashboard filter of type "ID" intended to filter users by their organization. However, I'm facing two main issues:
- Incorrect Display: The filter's dropdown list displays the organization
ObjectId
s instead of their names, despite being configured to display the name field. - No Results on Filter: When I select an ID from the dropdown, the query returns "No results!".
Key Finding (Cause of "No Results"): After extensive troubleshooting, I've found the cause of the "No results" issue. The auto-generated query preview shows that Metabase is using an array of Strings in the $in
clause, instead of casting them to ObjectId
.
This is incorrect, as I have confirmed that both Organization._id
and User.organizationId
are stored as the native ObjectId
type in our MongoDB database.
Here is the incorrect query being generated:
Steps & Configurations I Have Already Tried Without Success:
- Data Model Configuration:
- I have correctly set up Semantic Types:
Organization._id
is an Entity Key.Organization.name
is an Entity Name.User.organizationId
is a Foreign Key pointing toOrganization._id
.
- I have inspected the base "Field Type" for these fields, but the option to select "MongoDB ObjectId" is not available in my UI. I suspect this is the root of the problem, as Metabase doesn't seem to recognize the underlying data type and I cannot manually force it. (I will attach a screenshot of the available "Field Type" options).
- Question & Filter Setup:
- The source question for the dropdown (
Lista organización
) correctly outputs both the_id
andname
columns. - The target question to be filtered (
Lista de usuario
) has a variable of type "Field Filter" with its internal filter type set to "ID". - The dashboard filter is type "ID" and successfully connects to the question's variable.
- In the filter's dropdown value configuration, the "display column" ("Columna que produce los valores") is set to the
name
field. The preview in this config screen does correctly show the names, but the live filter on the dashboard still shows the IDs.
- Troubleshooting Steps:
- I have performed multiple hard refreshes (
Ctrl+Shift+R
) and tested in incognito/different browsers to rule out client-side caching. - I have deleted and recreated the dashboard filter from scratch.
- I tried changing the dashboard filter type to "Text or Category" as a diagnostic test, but this breaks the connection to the question's variable (which expects an ID), so it's not a viable path.
Despite all of this, the problem persists. The dropdown shows IDs, and the generated query is incorrect, leading to no results.
Has anyone experienced this behavior or have any insight into why Metabase wouldn't be generating ObjectId()
in the query for this Field Filter? Is there a way to force this data type if it's missing from the Data Model UI?
Thank you in advance for your help!