Hi. I am trying to set up charts using an aggregation. My question is how do i apply a filter on a document if the project stage only outputs the new fields I created. I use certain fields in the pipeline and even if I carry them through to the end it doesn’t seem that the filter applies to within the pipeline. I want to apply the filter to a field that is present in the original document and then want it to change the result of the aggregation. Below i will attach a pic of the aggregation as well as my data setup. So i am trying to see all the stats that each individual player performed which is listed under the value key. Later i then want to be able to filter on the value and that should then exclude certain player numbers.
Sometimes few small visual examples better than 1000 words
- prettified document example from your collection. You can get it with db.your_collection.findOne();
Hi @johan_potgieter -
I think you’ve already figured out a lot of this, but you may want to look at this article which explains how Charts builds its aggregation pipelines: https://docs.mongodb.com/charts/saas/aggregation-pipeline-generation/
Your challenge is that the your embedded charts can only influence the pipeline at a specific point (#4 in the list). So anything that you want to filter on must be set up in one of the preceding stages, e.g. a chart query or data source pipeline. Since those cannot be parameterised, you may not be able to solve your problem but I’m not sure I fully understand the scenario.
This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.