Skip to Main Content

MongoByte MongoDB Logo

Welcome to the new MongoDB Feedback Portal!

{Improvement: "Your idea"}
We’ve upgraded our system to better capture and act on your feedback.
Your feedback is meaningful and helps us build better products.

Status Submitted
Categories Charts
Created by Guest
Created on May 29, 2020

Possibility to use filter parameters in later stages

We use embedded charts with aggregate queries for comparison of multiple date values. In our case, we are in conversations, we want to know for a certain week how many conversations were started and how many finished. We do this book filtering on $or for the startdate to be in range OR the finished date to be in range. This works well. The problem is that later on, for instance in my aggregate query I would like to use the filter values pushed in by the embed URL, for instance in $group or $facet stages. Suggestion : make the filter values usable in later stages by making them callable using $$filter_val_1, $$filter_val_2, and so on.
  • Guest
    Sep 30, 2020
    Hi Tom, that sounds like a very nice solution and it's portable to other types of filters as well.
  • Guest
    Sep 7, 2020
    Thanks for the suggestion Arnold! We're looking at how best to handle this scenario. Rather than tie it to filters, we were thinking of adding a new method to the SDK that would let you do something like: chart.setField("startDate", new Date("2020-09-07")) This would result in the requested value being added early in the agg pipeline for each document, i.e. with: { $addFields: { startDate: ISODate("2020-09-07") } } Then if you wanted to leverage it in your own query, you could simply refer to "$startDate" and it would contain the value set from the code. Let me know if you think this will work.