Allow to process totals
Allow the charts to do calculations on the totals, say we fields: [currentAmount, renewedAmount]
And the chart shows as totals [1000, 800]
Then it should allow to show it as .80 (or 80% with formatting), at least in a Text, Number Chart.
Keep in mind, since so far what I've researched we can only do calculations on each field then it would not be possible to add ratios per document.
-
AdminTom (Product Manager, MongoDB) commented
Thanks for the suggestion Gabriel.
Just to make sure I understand the request: currently it is possible to add calculated fields (which can be used for things like ratios), however these fields are calculated per-document. So I think you want something like calculated fields that apply to the encoded/grouped values, for example on the total values from all documents?
That's a fair feature request. If you need this now there is a workaround which is to pre-group the data in a pipeline, e;g:
[ { $group: {
_id: {}, totalCurrent: { $sum: '$currentAmount' },
totalRenewed: { $sum: '$renewedAmount' }
}]...and then you can calculate the ratio using a calculated field, or a separate $set stage in the pipeline.