Find document position in result after aggregation

Find position of document in aggregation result and add it in same output
e.g


i want deliveredUnits 12 position to 2 with newly added field in same collection
with mongodb version 4.4 version

Hi @Ashish_20501 ,

What you want is $rank available only from 5.0 .

For 4.4 there is tricks for ranks and dense rank :

Thanks
Pavel