Database

db={transaction:[{/**"_id":"identifier",*/"schedule":1,"uniqueCode":"312312312312","created":"Date","status":"Active"},{/**"_id":"identifier",*/"schedule":1,"uniqueCode":"1213123123","created":"Date","status":"Deleted"}],schedule:[{"_id":1,"start":"date","end":"date","location":101},{"_id":2,"start":"date","end":"date","location":102}],location:[{_id:101,name:"Location A"},{_id:102,name:"Location B"}]}

Query

db.schedule.aggregate([{$lookup:{from:"transaction",let:{scheduleId:"$_id"},pipeline:[{$match:{$expr:{$and:[{$eq:["$schedule","$$scheduleId"]},{$eq:["$status","Active"]}]}}}],as:"transactions"}},{$lookup:{from:"location",localField:"location",foreignField:"_id",as:"location"}},{$set:{location:{$first:"$location"}}},{$group:{_id:"$location._id",location:{$first:"$location"},total:{$sum:{$size:"$transactions"}}}},{$sort:{"total":-1}},{$limit:10},{$project:{_id:0,locationName:"$location.name",total:1}}])

Result