Is it possible to export an aggregation to Mongo Charts?

Hi, I started using MongoDB towards the end of August and so far I’ve only had to make queries and inspect data for which I used Compass. Recently I’ve been tasked with creating more informative dashboards that require complex aggregations and drawing in data from multiple collections before doing some of the aggregation steps.

I’ve been going through Mongo’s M121 course and finally I was able to make some useful aggregation pipelines in Compass. Now I need to carry out these aggregation steps in charts to deliver useful information, but the problem is that lookup is not available in charts (not in the query bar at least).

My problem is the following: Let’s say I have an aggrgation with the following steps:

  1. project
  2. lookup
  3. project
  4. project

Then, even though I’ve spent ages crafting my aggregation pipeline in Compass I need to redo most of it in charts. On top of this, the graphical interface for adding fields in Charts is hard to use, and several times it just reports that “no result was found” without further explanation. I’ve also tried to remove the lookup aggregation from the Query bar and do it manually, but this also results in an empty dataset.

Is there any way to export some aggregation done in Compass directly to Charts? If not, most of the functionality of Charts is useless to me, since I can’t get any aggregation step to work once do the lookup, which is usually very early in the aggregation pipeline. There must be a better way to do this.

I’ve spent most of my day trying to figure this out, any help would be appreciated!

Hi @Gregory_Swart ,

If you use stages like $lookup you need to first add all lookup collections in the data source page. Additionally, you need to preprocess this lookup in the data source “add pipeline” stage where you can pass the compass exported pipe.

Of course if you need each collection as seperate data source you can add as many variations as you want.



Thank you, this is exactly what I was looking for!

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.