I'm using Obsidian daily notes to keep track of the time spent on various projects at work that fall under the categories of "research", "teaching", or "service". I'd like to use the Dataview plugin to produce a table that lists the total hours spent on each project and the totals for each category.

I'm keeping track of hours in the frontmatter YAML of my daily notes like this,

--- 
research: 
  project1: 1 
  project2: 2.5 
service: 
  committee1: 2 
  committee2: 1.5
teaching:
  class1: 0
  class2: 3 
--- 

How can I make a Dataview or Dataviewjs query that will return the total amount spent on each project/committee/class and the total time spent on the parent categories (research, service, and teaching)?

I have read the Dataview documentation, but I'm new to SQL-like queries and have no experience with Javascript, although I'm trying to figure it out. There isn't anything that talks about using nested YAML keys in queries at the parent level.

I started with the following, but in the Total column for each day it returns and incomplete list of the projects. For instance, the first row is
| May 9, 2023 | 12 | 8 | -Project1: 4 -Project2: 2 |
So the values in columns 2 and 3 are correct, but the values in column 4 are from only one of the notes.

TABLE 
sum(nonnull(rows.research.project1)) AS "Project 1",
sum(nonnull(rows.research.project2)) AS "Project 2",
sum(nonnull(rows.research)) AS Total,
FROM "Daily Notes"
GROUP BY file.cday AS "Date"

I'm open to workarounds*, but the sub-projects will change from time to time, so if my query had the equivalent of project1 + project2... I would need to periodically update it and eventually the equation would be a mile long. Having it recognize the parent category would be ideal.

*I realize there is a shitty workaround of just creating a researchTotal: key and doing the simple math at the end of the day to enter the total manually, but that's no fun. I want to learn something new.


EDIT This question was asked before the release of Obsidian 1.4 which introduced properties as the frontmatter. It doesn't appear to support nested keys at all, so this question may no longer be relevant to Obsidian. I more or less gave up on the problem I was trying to solve anyway.

0

There are 0 answers