I'm trying to make a groupBy on mongoDB, using cond to select to appropriate field, however, mongo is giving me: "The field '$cond' must be an accumulator object"
$group{
"_id" : {"dateId" : "$dateId"},
"estimated" : { "$sum" : "$estimated_records"},
$cond: {
if: {"activeSelfConsumption" : {"$exists" : true}} , (I'm also not sure if this work)
then : {"value" : { "$sum" :"$activeSelfConsumption"}},
else : {"value" : { "$sum" :"$active"}} }
}