Hello @Vasco_Pedro, welcome to the MongoDB Community forum
Please include an example document and the aggregation query you are working with, so as to get a better idea what you are trying. It is little difficult to visualize what you are trying.
Welcome to the MongoDB community forums @Vasco_Pedro!
In addition to @Prasad_Saya’s suggestions, it would be helpful to confirm the MongoDB server version you are using (for example, via the output of db.version() in the mongo shell).
There have been improvements to aggregation features in successive major releases of MongoDB, so there may be more efficient ways to achieve your desired outcome depending on your MongoDB server version.