I would like to calculate the percentage increase of some data in the database between two months. But as much as I think about it, I can’t find the aggregate.
Id: 12548
name: jhon
expence: 200$
day: 22-3-2022
id: 15426
name: mary
expence: 150$
day: 15-4-2022
more or less
calculate increase percentage between two month
{
$setWindowFields: {
partitionBy: {“$month”:”$day”},
sortBy: { day: 1 },
output: {
sumExpence: {
$sum: "$expencel",
window: { documents: [ -1, 0 ] }
},
previousDateTime: {
$push: "$date",
window: { documents: [ -1, 0 ] }
}
}
}
}
Something idea??
thank you