With the purpose of organising my writing, I’d like to query a list of notes with a count of different types of tags within each note. This would provide me a snapshot of the type and amount of work that needs to be done in each note, and overall to complete the writing project.
I’m new to Dataview and haven’t tried any code yet, but hopefully this explanation provides enough context. I’d also be curious to read about different approached developed around similar use cases.
Hi @paoloap I don’t see an example of what you’re wanting for a final output, but the Dataview plugin should do what you’re looking for.
If you want a table of pages with the counts of tags on each page you can do the following:
```dataview
TABLE
length(tags) as numtags
, "#" + join(tags, ", #") as tags
FROM
#docker or #kubernetes
```
Which will give output similar to the following:
If on the other hand you’re wanting a table of tags and the number of pages that they are on, then you need a little more involved dataview query:
```dataview
TABLE
length(rows.file.name) as numfiles
, join(rows.file.link, ", ") as files
FROM
#docker or #kubernetes
flatten
file.tags as tag
group by
tag
```
Hey Dug, thanks a lot for taking the time, it is exactly what I was looking for.
I could implement the 2nd solution straight away but something is going on with the 1st one. The snippet could correctly filter the note but fails to count the number of tags.
The syntax seems correct to me, I’m sending a screenshot to help you debug what’s going on.
Since your dataview query is searching on tag #important I would assume that there is at least one tag on the page. In testing I was able to get similar results as you if I use an inline tag. Based on that, I have an updated query for you to try:
```dataview
TABLE
length(file.tags) as numtags
, join(file.tags, ", ") as tags
FROM
#docker or #kubernetes
```
This appears to work as expected for me with tags in either the frontmatter or inline in your note. Doing this also removes the need to append the # on your tags to make them searchable.
It looks like tags just looks at the frontmatter, where file.tags looks at the entire document.
Thank you for teaching me something new by making me try new things. That helped in making my understanding of the tool and plugin better. Seems I have much left to learn about things.
if anybody is learning… believe it’s me. You stepped up my Obsidian game considerably
I’m excited by what this plugin makes possible and went through the documentation so many times, but I feel I’m missing some preliminary knowledge needed to fully understand the queries and what’s possible.
Can you direct me to some useful resource where I can learn?
What I’ve learned is from reading posts here and playing around. The docs are a good place to start, but I don’t feel that they give enough examples to understand how best to utilize thing to their fullest potential. If I come across any good sites with examples I’ll send you a DM.