First Released: 2024-02-10 Changes or Retractions: N/A # TLDR Been off sick recently, so I've not had too much time to write. (Though I'm on notebook [[Notebook Overload - Seeking Digital Zen|number 7]] that I'm carrying around). I was playing around with my templates the other day and noticed a few things. You `group by` in data view query has a count function. An area that has had many a [forum post](https://forum.obsidian.md/t/help-with-using-dataview-to-get-task-count/47525) with no elegant solution (alot that can go wrong, requirements for a set format, alot of maintenance required for single changes). # Explanation In [[Dataview]] there is a feature where you can group outputs by a specified criterion. Below is an dataview list of all task grouped by the file created date. ``` TASK Group by file.name ``` Typically, the output looks like this. ![[Pasted image 20240210173002.png]] You can see that it has successfully grouped as asked. It also counted the number of items that fits in each grouping. This is useful to a degree. After trial and error in my [[Black Box Testing]] method. I've found that the function works to evaluate the groups second after finding an overall count. This means that if the group by evaluation is done and an error is found where the grouping category doesn't exist the query doesn't crash, it outputs the full list with the count. Using this bug I've managed to get a low cost count of all tasks that meet the criteria I set in where clauses. Below is the output of a [[Weekly Note]] query. ![[Pasted image 20240210173749.png]] By setting the group by value to a random string, we break the grouping after the count. ![[Pasted image 20240210173915.png]] This results in a simple count appended to the top with no breakdown. ![[Pasted image 20240210174034.png]] ## Usage Total Tasks Done or created in any scope, Total files created or modified works for other data types as well. Advantages: - Great to get quick totals where needed. - No technical speciality needed. - Minimizes the maintenance cost to get totals from [existing solutions](https://forum.obsidian.md/t/help-with-using-dataview-to-get-task-count/47525) - Overall is a cheaper query as it requires less virtual memory to be utilized and thus removes performance hits. Risk: - May be fixed in the future