The challenge arises when some entries have multiple categoryIds, resulting in difficulties in proper grouping
I was able to group the data with the '$distinct' method, but some of the data has more than one categoryId, which causes problems in grouping. How can I group categoryIds that are an array?
JSONata: https://try.jsonata.org/79QRdDXs9
You should create on map for categoryId as key and object of data as value.