User.aggregate([ { /* Filter out users who have not yet subscribed */ $match: { /* "joined" is an ISODate field */ 'subscription.joined': {$ne: null} } }, { /* group by year and month of the subscription event */ $group: { _id: { year: { $year: '$subscription.joined' }, month: { $month: '$subscription.joined' } }, } }, { /* sort descending (latest subscriptions first) */ $sort: { '_id.year': -1, '_id.month': -1 } }, { $limit: 100, }, ])