How to COUNT number of times a tag appeared in notes from my Journal?

Things I have tried

Tried to use alias and tags and count (length(rows) but the table is displaying as blocks per note instead of summarising by alias or tags

I tried searching “How to count the number of times tags appeared in my notes from a particular folder”

What I’m trying to do

I have a daily journal, where I input tags as “topics” of what happened in my day (or topics related to that day - ex: work, travel, health etc.).

I want to have a table (using dataview) where I summarise the number of times a tag appeared in my notes and sort descending.

TOPIC | Count
Health | 7
Work | 5
Travel | 2

Is there a way to count across multiple notes from a specific folder? If yes, is it best to use alias or tags?

Try to build a dataview query where you use group by tags, and sum up the tags.

Report back if you get any problems, but please try and show us your attempt.

What you suggest makes sense to what I’m trying to achieve.
I’m entirely new to Obsidian & Dataview (learning about it over the last two days).

Do you mind pointing me in the right direction, to SUM UP those tags?
I’m looking at the DataView documentation but can’t find this function.

TIA

You can start by a list of tags per file… only after that you can jump to the next challenge: group by tags and count (using length()).

But you need to start with something. (And, of course, it requires some time to learn how the plugin works and how the metadata structure).

On point: if you use multiple times the same tag in the same note/file, it only counts one time (as the obsidian tag panel).

2 Likes

Maybe this resource, could get you going on the right track:

2 Likes

After a few mistakes, I came up with:

TABLE length(rows.file.name) as Count
FROM "Documents/Journal/Daily Journal" 
FLATTEN file.tags as Topic
GROUP BY Topic 
SORT length(rows.file.name) desc 
LIMIT 10

It worked perfectly and helped me to create a TOP 10 topics using Tags!
Now, what I’m wondering is: will it work the same way with new YAML keys I’m creating?
I want to use tags across all notes while using topics specifically for the folder with my journal.

1 Like

It helped me A LOT!!!

Thanks you so much

It should work the same, yes. And if not, it’ll be easier to help you and give specific help when we see what you’ve tried so far.

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