# Query count and grouping

**URL:** <https://community.silverbullet.md/t/query-count-and-grouping/1607>\
**Category:** General\
**Created:** [January 7, 2025, 6:45pm UTC](https://community.silverbullet.md/t/query-count-and-grouping/1607 "2025-01-07T18:45:30Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![disoardi](https://community.silverbullet.md/user_avatar/community.silverbullet.md/disoardi/32/877_2.png) [@disoardi](https://community.silverbullet.md/u/disoardi)\
**Post date:** [January 7, 2025, 6:45pm UTC](https://community.silverbullet.md/t/query-count-and-grouping/1607/1 "2025-01-07T18:45:30Z")

</div>

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:

````auto
```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

````

```auto

```

---

<div class="post-metadata">

**Author:** ![zef](https://community.silverbullet.md/user_avatar/community.silverbullet.md/zef/32/7_2.png) [@zef](https://community.silverbullet.md/u/zef)\
**Post date:** [January 8, 2025, 6:46pm UTC](https://community.silverbullet.md/t/query-count-and-grouping/1607/2 "2025-01-08T18:46:52Z")

</div>

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

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

````

---

<div class="post-metadata">

**Author:** ![disoardi](https://community.silverbullet.md/user_avatar/community.silverbullet.md/disoardi/32/877_2.png) [@disoardi](https://community.silverbullet.md/u/disoardi)\
**Post date:** [January 9, 2025, 2:00pm UTC](https://community.silverbullet.md/t/query-count-and-grouping/1607/3 "2025-01-09T14:00:44Z")

</div>

> [@zef](#):
>
> ````auto
> ```template
> Total pages tagged with #person: {{count({page where tags = "person"})}}
> 
> ````
> 
> ```auto
> 
> ```

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?

---

<div class="post-metadata">

**Author:** ![zef](https://community.silverbullet.md/user_avatar/community.silverbullet.md/zef/32/7_2.png) [@zef](https://community.silverbullet.md/u/zef)\
**Post date:** [January 9, 2025, 2:36pm UTC](https://community.silverbullet.md/t/query-count-and-grouping/1607/4 "2025-01-09T14:36:05Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![e-v-o-l-v-e](https://community.silverbullet.md/user_avatar/community.silverbullet.md/e-v-o-l-v-e/32/1713_2.png) [@e-v-o-l-v-e](https://community.silverbullet.md/u/e-v-o-l-v-e)\
**Post date:** [September 20, 2025, 5:50pm UTC](https://community.silverbullet.md/t/query-count-and-grouping/1607/5 "2025-09-20T17:50:34Z")

</div>

hey, is there any way to count query’s results in v2 ? I’m trying to count the time a specific task (with the same name) is done in several files  
(to note presence at a class)

---

<div class="post-metadata">

**Author:** ![zeus-web](https://community.silverbullet.md/user_avatar/community.silverbullet.md/zeus-web/32/571_2.png) [@zeus-web](https://community.silverbullet.md/u/zeus-web)\
**Post date:** [September 22, 2025, 2:10pm UTC](https://community.silverbullet.md/t/query-count-and-grouping/1607/6 "2025-09-22T14:10:40Z")

</div>

To get a count of all results of a query, just add a “hash sign” (#) in front of the query, like so:  
`${#query[[from index.tag "page"]]}`

---

<div class="post-metadata">

**Author:** ![disoardi](https://community.silverbullet.md/user_avatar/community.silverbullet.md/disoardi/32/877_2.png) [@disoardi](https://community.silverbullet.md/u/disoardi)\
**Post date:** [November 20, 2025, 2:59pm UTC](https://community.silverbullet.md/t/query-count-and-grouping/1607/7 "2025-11-20T14:59:57Z")

</div>

Ok, but if I wont to count all document that have the field “End date” between 2024-01-01 and 2024-12-31?

With silverbullet v1 I used this: {{count({page where tags = “book” and status = “Completed” and year(`End date`) = “2025”})}}.

How can reproduce in v2?
