Hi, have a question on using Mongo Charts and filters. I had originally implemented the iframe deprecated solution and saw some of my charts were not loading correctly. So I switched to the jwt method with authenticated users, only to find in the last stage that the problem persisted… The last stage was adding filters.
I have a few aggregation queries that basically do this:
- $match based on values being present (answer to a question)
- $addfields to modify the string answer to an int
- $facet to put the int values into buckets
- $project to do some calculations on the values (calculate an NPS score)
When I run this chart on the dashboard with a date filter everything works fine. The problem is that I cannot add the createdDate field to the list of filters allowed in embedding, since it is not there. I have found with other queries that I actually need to project the date field through all stages to make it selectable as a filterable parameter, which seems odd as I believe to have read somewhere that the filters are a special $match fase at the beginning of the query (which also seems the way it works on the Charts dashboard).
- Is it by design that I need to project the filter fields all the way through aggregation queries?
- How would that work on queries that use a $facet fase where I cannot project a date per record?
- Any other way to solve this?