Is the field profit_real
an actual field in your documents? Or is it a field you are computing - if so then I believe it might be computed after your $setWindowFields
stage runs. If it’s being computed (it appears to be a sum of profit
and commission
) then just replace $profit_real
with expression that computes it - like {$sum:{$add:["$profit","$commission"]}}
Asya