Dashboard Filtering on Mongo Aggregated Pipeline Result

Question: How can I apply a dashboard filter to Mongo Aggregation Pipeline documents

What I did:

I’m using the Question Query Editor to build an aggregation pipeline to make the data more suitable for presentation in a table (raise all the embedded documents up to a single flat record what we typically expect of a table row). For example:

    { "$unwind": "$hosts"},
    { "$addFields": {
                    "name": "$hosts.name",
                    "pool": "$hosts.pool",
                    "profile": "$hosts.profile"

    { "$project": {"_id":1, "name": 1, "pool": 1, "profile": 1}}

When I added the Question to the dashboard and then add a filter, the question tab displays “No Valid Fields”. The filter I selected was ID. This field (_id) is the original _id field (i.e. it was not one of the fields added during the pipeline) and I explicitly included it in the aggregation “project” above so that you can see that it is present.

If I look at Admin Panel > Data Model > Database -> Table -> Columns I can see the “Type” is set to “EntityKey” for the _id field. For giggles, I set this field to a Type of Category and then attempted to add a Category filter in the dashboard, but that didn’t help either.

If see in the SQL Parameters documentation (https://metabase.com/docs/latest/users-guide/13-sql-parameters.html#the-field-filter-variable-type) that you can flag a field with the {{}} syntax and then nominate the field filter type, but this doesn’t appear to work in the Mongo query editor.

Any ideas how I can filter data from a Mongo aggregated document?

If you are reporting an issues or asking for help, pretty please include your Metabase, Operating System and Browser versions. If you think it’s a bug, please try to replicate it using our sample dataset if at all possible.

Metabase version: You’re on version v0.27.1 - Built on 2017-11-29
Operating System: Red Hat Enterprise Linux Server 7.3 (Maipo)
Browser: Safari 11.0.2

So no way to Dashboard filter results that have been generated from a Mongo query?

Is this still an issue?

@ChristineChetty No, Field Filters are supported in MongoDB as of 0.34.0

1 Like