Periodically resetting cumulative data

My team and I have recently figured out how to create a cumulative graph across multiple categories in Mongodb Atlas Charts. The X axis is time and the Y axis, or response variable, is the cumulative total. What we are looking to do now is to insert something in the aggregation pipeline that allows us to reset the cumulative total for each category to zero after every day. Any ideas or suggestions will be appreciated. Thank you.

Hi @Matthew_Taylor -

You can’t do this with the “compare values” option in Charts, but you can likely achieve this by using an aggregation pipeline that uses Window Functions. I don’t have the exact query for you, but you should be able use a $sum window operator over the preceding day to achieve this.

Tom