Query count and grouping

Hello everyone, I’m writing because I’m new to the world of SilverBullet and I haven’t understood how to perform a count on a query. Specifically, I log the start and end dates for each book I read; then, on a recap page, I’d like to count how many books I finished in a year.

In Obsidian, I used Dataview with the following query:

```dataview 
table length(rows) as count
Flatten row["End Date"] as d
where pgType = "book" AND d != null
group by d.year as year
sort year DESC

There’s no group by support yet, you can do counts on queries though, e.g.

```template
Total pages tagged with #person: {{count({page where tags = "person"})}}
```
3 Likes

Hi and thank you. I tried it out and it works, but I encountered a problem with the properties, specifically with spaces like End date. The error message is:

Error: Parse error in: count({page where tags = “book” and year(End date) = “2025”})

I’ve tried escaping the space with a backslash (End\ date), but it didn’t work. How can I fix this?

You can put backticks around fields with names: `End date`

1 Like