Thanks for the sample data, which makes it a lot easier to help you. In your query you’re actually grouping on the list of categories, so you would only “remove” duplicated lists, and not duplicated singular categories.
To handle each category on its own you need to split up the lists, by doing something like FLATTEN categories as category, and then GROUP BY category. This results in the following query:
```dataview
LIST
FLATTEN categories as category
WHERE categories
GROUP BY category
```
In my test setup, that simplifies all the various definitions of categories into a single list of the unique values.