Maybe I was not very clear about the issue of files and folders: was on how these elements appear in the desired table - lists of files and lists of folders for each tag.
But the best way to clarify this is advancing with hypotheses for your table.
- Table with “folders” and “files” presented as lists:
```dataview
TABLE WITHOUT ID (tag + "(" + length(rows.file.link) + ")") AS Tags, (rows.file.folder) AS Folder, (rows.file.link) AS Files
FROM ""
WHERE file.tags
FLATTEN file.tags AS tag
GROUP BY tag
SORT length(rows.file.link) DESC
```
- Table with “folders” and “files” presented as joined lists:
```dataview
TABLE WITHOUT ID (tag + "(" + length(rows.file.link) + ")") AS Tags, join(rows.file.folder) AS Folder, join(rows.file.link, ", ") AS Files
FROM ""
WHERE file.tags
FLATTEN file.tags AS tag
GROUP BY tag
SORT length(rows.file.link) DESC
```