I am currently trying to create a calculated field: where we divide the sum of total ad spend by sum of total views then multiply by 1000. However, this query currently leads to an “Unexpected “:” at character 50”
db.CreatorStats.aggregate([
{
$group: {
_id: null,
totalAdSpend: { $sum: "$Ad-Spend" },
totalViews: { $sum: "$Views" }
}
},
{
$project: {
_id: "null",
result: {
$multiply: [{ $divide: ["totalAdSpend", "totalViews"] }, 1000]
}
}
}
]);
My database looks like below