MongoDB Charts - Aggregation Pipeline to get most recent value and CummulativeSum of a field

Well spotted @Asya_Kamsky. You can tell that profit_real is a calculated field as it is shown in italics in th left pane. You could either do what you suggested in the $setWindowFields stage, or move the calculated field to the top by defining it in the query bar using $set instead of using the calculated field feature (which does the exact same thing, but at a different stage in the pipeline).

@Dilip_Rajkumar note you can use the “View Aggregation Pipeline” from the … menu to see the complete pipeline being generated by the chart definition, which can be a helpful way of debugging these complex problems.

Tom

2 Likes