Can I get the number of per tags within notes?

I referred to the this post and used the following code,

```dataviewjs
const topicFiles = dv.pages('"Some pages"')
	.flatMap(p => {
		const tFile = app.vault.getAbstractFileByPath(p.file.path)
		const allTags = app.metadataCache.getFileCache(tFile).tags
		return allTags
	})
	.map(t => t.tag)
	.groupBy(t => t)
	.map(t => {
		return [ t.key, t.rows.length ]
	})
	
dv.table(["Title", "Numtags"], topicFiles)
```

I got this

image

and this results matches the number that comes out when searched with tags!

We’re almost there…

finally, I would like to see the calculated value for each note, rather than flattening all the notes together.

Is it possible?

1 Like