Count a specific character in file using dataview

Things I have tried

I’ve tried searching for this both here and on teh interwebz but no luck.

What I’m trying to do

I’m trying to collect the number of times a specific character is found in a file using dataview.

For instance, I might have a file stuff:

- item 1  ✅
- item 2 
- item 3  ✅
- item 4  ✅

I keep hoping there’s a way to ask dataview to look at that specific file and count how many times it finds the character :white_check_mark:. Right now, I am just manually counting them, and that works, but if the items in the file grow too long, I’ll probably get the number wrong. And I’d like it to stay correct.

Ideally, I’d love an inline query, but even a list without id or table would work if I could just get that number automatically.

I haven’t used dataview, but if nothing turns up you could use the Regex Find/Replace community plugin to delete every character except the one you want to count, then look at the character count in the Word Count core plugin and undo the deletion. (Or copy to a new note before deleting.)

Not super smooth, but prolly better than counting by hand.

If this is only for checklists, you might consider using the built-in checklist format (-[ ]), which there is prolly a core or community way to count.

My suggestion:
1 - using inline fields with format (key:: value) and enable inline field highlighting in settings > dataview (with this format/option you only see :white_check_mark: in preview/reading mode):
2 - example:

- item 1 (done:: ✅)
- item 2 
- item 3 (done:: ✅)
- item 4 (done:: ✅)

3 - inline query (to be placed in current note):

`=length(this.done)`

4 - inline query (to be placed in other note):

`=length([[yourtargetnote]].done)`

Thanks! I can definitely modify the notes to make this work.

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