How many notes have this hashtag?

In one vault I’m using Obsidian as a sort of customer relationship management. I’m a wedding celebrant and each client gets a note, and I’m filtering to-do’s for each client using hashtags.

I’ve read about other users having a Dashboard note, and that lead me to thinking, a Dashboard note for me that communicated x number of notes have this hashtag etc, would be really helpful.

Anyone able to point me towards this kind of setup?

Hey Joshua,

Here are two solutions that might work for you, both are shown in my screenshot below.

  1. For a simple tag count, the Tags pane on the right will show the number of instances of any tag (though this counts instances of the tag, not the number of notes using a tag, i.e. a tag might be placed in one note multiple times).

  2. The Dataview plugin allows you to pull a list of all notes with a certain tag into a table, in my screenshot I also have a simple CRM and have used a query that lists all notes with the #contact tag. I haven’t figured out a way to show the total number of notes that are being shown here but I think it’s possible - maybe someone with more Dataview experience can chip in here :slight_smile:

2 Likes

Something like

#test (`$= dv.pages("#test").length`)

Result:

#test (5)

3 Likes

@Moonbase59

I tried that snippet with and without the ```dataviewjs, and I get an error related to the #test at the beginning.

“Evaluation Error: SyntaxError: Unexpected identifier…”

If I remove the #test from the beginning it evaluates to nothing. I changed the tags to a tag I know I have a hundred of, “#concept”, and I still get nothing.

I have Dataview with the js query turned on. I’m just entering this into a blank note.

What is missing.

It’s a javascript inline query.
You must use only this:

`$= dv.pages("#test").length`

4 Likes

Thank you @mnvwvnm

I have 42 concept tags, not 100.

The Note automatically adds the ``` before and after when you hit enter, I had to remove those to get it working.

Moonbase59’s syntax worked as well. It was the automatic ``` causing the issue.

#concept ($= dv.pages("#concept").length)

Result:
#concept (43)

lol, it counted the extra #concept in the code. Good to know.

The single apostrophes are being edited out by this editor. Follow mnvwvnm’s picture example.

Yup. Code copied from the forum directly into Obsidian will most often be “code-fenced”. You can avoid that by doing a “paste as plain text” from the context menu, or Ctrl+Shift+V.

The #type tag before and the parentheses should only serve as an example.

1 Like

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