Database

[{"_id":ObjectId("639755094ab8f1702b3b661a"),"Id":"Tom","otherId":"Jack","source":"proposal","year":"2017"},{"_id":ObjectId("6397550a4ab8f1702b3b6ff7"),"Id":"Tom","otherId":"Jack","source":"grant","year":"2018"},{"_id":ObjectId("6397550a4ab8f1702b3b7336"),"Id":"Tom","otherId":"Jack","source":"tech","year":null},{"_id":ObjectId("6397550b4ab8f1702b3b75ae"),"Id":"Tom","otherId":"Jack","source":"proposal","year":"2019"},{"_id":ObjectId("6397550b4ab8f1702b3b7a03"),"Id":"Tom","otherId":"Jack","source":"proposal","year":"2018"},{"_id":ObjectId("6397550b4ab8f1702b3b7a01"),"Id":"Sarah","otherId":"Edward","source":"proposal","year":"2018"},{"_id":ObjectId("6397550b4ab8f1702b3b7a04"),"Id":"Sarah","otherId":"Edward","source":"grant","year":"2018"}]

Query

db.collection.aggregate([{$group:{_id:{Id:"$Id",otherId:"$otherId"},count:{$sum:1},source:{$addToSet:"$source"}}},{$project:{_id:0,Id:"$_id.Id",otherId:"$_id.otherId",count:1,source:1}}])

Result