Dataview: Group list by tag

Hello, is it possible to create a table with Dataview and group lists by tags? Let me detail it with an example.

I have three notes:

⁠2024-02-28.md

- lorem ipsum #AI
- lorem ipsum #Business
- lorem ipsum #Code

2024-02-29.md

- lorem ipsum #AI

2024-03-01md

- lorem ipsum #Business
- lorem ipsum #Code
- lorem ipsum #Code

And I want to have this as result:

| Tag       | File       | Text          |
| --------- | ---------- | ------------- |
| #AI       | 2024-02-28 | - Lorem ipsum |
| #AI       | 2024-02-29 | - Lorem ipsum |
| #Business | 2024-02-28 | - Lorem ipsum |
| #Business | 2024-03-01 | - Lorem ipsum |
| #Code     | 2024-02-28 | - Lorem ipsum |
| #Code     | 2024-03-01 | - Lorem ipsum |
| #Code     | 2024-03-01 | - Lorem ipsum |

I’m using those Dataviews but I don’t figure out how to combine both :confused:

For list all tags per notes:

TABLE LENGTH(rows.file.name) AS Count
FROM "Daily Notes/2024" 
FLATTEN file.tags AS Topic
GROUP BY Topic 
SORT LENGTH(rows.file.name) DESC

And for displaying all lists with tag “#AI”:

TABLE
L.text AS Subject
FROM "Daily Notes/2024" 
FLATTEN file.lists AS L
WHERE CONTAINS(L.tags, "#AI")
SORT file.name ASC

Thanks in advance!

I solved it with

TABLE
	L.tags as TAG,
	L.text as TOPIC
FROM "Daily Notes/2024" 
FLATTEN file.tags AS tags
FLATTEN file.lists AS L
WHERE contains(L.tags, tags)
SORT file.name ASC
SORT L.tags

And how it looks like:

Keep in mind that will be ordered by tags and then ordered by filename.

Your solution will also potentially duplicate lines of you’ve gir multiple tags and list elements… Just saying

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.