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

Hi Dilip -

A simple query (in curly braces) is just a shorthand for a $match aggregation stage. So you can combine the two like this:

[
  { $setWindowFields: { ... } },
  { $match: { entry: 1 } }
]

Unfortunately I’ve never used $setWindowFields myself so I can’t help debug why it’s not giving you the expected result.

Tom

1 Like