Aggregate count by value in mongo charts

I have users and their email ids,creation date in the document……i need to get company name from email id and group them by company…and then need to get count of users created per month…and this count should be cumulative every month and also should be showing count of each company’s count and name in the chart… I am able to get company name and get the cumulative count by using aggregate by count in charts but I need each company’s split in the total count and shown in the charts along with their names…its happening if i choose aggregate count by value but count is not correct…what can be done in this scenario…

Hi @Kranthi_Rayala, it would be helpful to see some screenshots that explain your problem. But as an alternative to using Count By Value, you could try using the regular Count aggregation for the _id field in the value axis and then put the thing you want to count by in the Series channel.

Tom

Hi Tom,
I tried the solution you have provided but I am not able to get cumulative total … I need to get cumulative total and names of company should be displayed.

Thanks for the extra info! Unfortunately it looks like Count By Value and Compare Periods don’t work well together. We generally restrict Compare Periods to single-series charts, and missed the fact that it can be enabled with Count By Value (which is another way of building multi-series charts).

The team is looking into what to do about this bug, but in the short term I suspect the best fix is not to rely on either feature and instead preprocess the data with a custom aggregation pipeline that uses window functions to calculate the cumulative total, as per this example.

HTH
Tom

Hi Tom,

Thanks for explanation. Our Mongo version is 4.4 and setwindows function is not available in this version. could you please suggest me any other workaround for this.

Thanks

Aggregate count by value in Mongo Charts is a useful feature for visualizing data in MongoDB. To use this feature, you’ll first need to create a chart in Mongo Charts that is based on a data source containing the values you want to aggregate. Then, select the “Aggregate” option from the “Data” dropdown in the chart configuration panel. In the “Aggregate” panel, you can specify the field you want to aggregate by selecting it from the dropdown menu. You can then choose the type of aggregation you want to perform to remini, such as a count of the number of occurrences of each unique value. Finally, you can customize the appearance of your chart to display the aggregated data in a way that makes sense for your needs. With this powerful feature, you can quickly gain insights into the distribution of values in your MongoDB data and use that information to make informed decisions about your business or project reels