Collect Absences with Dataview

First, search the help docs and this forum. Maybe your question has been answered! The debugging steps can help, too. Still stuck? Delete this line and proceed.

What I’m trying to do

I have built a vault for handling my students. I have a daily note that I take attendance. If a child is absent I click complete on a checkbox with their name. That tells me their name and the date they were absent. In a separate note with their name I want to check the entire semester and see how many times they were absent in a dataview window in their file. I’m trying to track all of a students absences throughout the year.

Things I have tried

Task
FROM "X School/7th Grade"
WHERE text = "Aisha X"
GROUP BY file.link 
SORT created ASC, rows.file.ctime ASC 
LIMIT 100 

Task
FROM “X School/7th Grade”
WHERE text LIKE “%Aisha X%”
GROUP BY file.link
SORT created ASC, rows.file.ctime ASC
LIMIT 100

I even let ChatGPT have a go at it and all I get are returned errors

Dataview: Error:
– PARSING FAILED --------------------------------------------------

1 | Task
2 | FROM “X School/7th Grade”

3 | WHERE text LIKE “%Aisha X%”
| ^
4 | GROUP BY file.link
5 | SORT created ASC, rows.file.ctime ASC

Expected one of the following:

‘*’ or ‘/’ or ‘%’, ‘+’ or ‘-’, ‘>=’ or ‘<=’ or ‘!=’ or ‘=’ or ‘>’ or ‘<’, ‘and’ or ‘or’, /FROM/i, EOF, FLATTEN [AS ], GROUP BY [AS ], LIMIT , SORT field [ASC/DESC], WHERE

In my daily form it looks like this
Absences

  • Name one
  • Name two
  • Name three … etc

If someone is absent I mark them off and it records the name and date. I want my dataview query to show me as I go through the year how many times that particular student has been absent for a quarter or semester or the whole year.

Can anyone help me.

OK, so this query is untested, but I could be lucky, and it could work:

```dataview
LIST length(rows)
FROM "X School/7th Grade"
FLATTEN file.tasks as task
WHERE task.status  = "x"
GROUP BY task.text
```

In theory it should pick out all the tasks which are completed, aka absent, and then group them together on the student name, and finally count how many times they’ve been absent.

Please report back, if this is what you’re looking for, or close to it. If only close, we might take a second look at it (or do some actually testing, which I didn’t do too much of now… :smiley: )

It could be that the date added, will break my query… How is the date recorded? Through completion using tasks or dataview? Is there anything else on the task text changing it from a pure name?

Maybe this works better?

```dataview
LIST length(rows)
FLATTEN file.tasks as task
FLATTEN regexreplace(task.text, " ?✅ ?\d{4}-\d{2}-\d{2}", "") as name
WHERE task.status = "x"
GROUP BY name
```

The first one works but it doesn’t sort by name and I only need it from one section. The “Attendance” section.

LIST length(rows) 
FROM "X School/7th Grade" 
where section.subpath = "Attendance"
[where meta(section)subpath = "Attendance"] doesn't work either
FLATTEN file.tasks as task 
WHERE task.status = "x" 
GROUP BY task.text 

The first one with the dates works better now I just need to filter by only one name “Student X”

LIST length(rows) 
FROM "X School/7th Grade" 
FLATTEN file.tasks as task 
WHERE task.status = "x" and task.text = "%Student X%"
GROUP BY task.text 

I found the solution.

  1. Use the Tasks Plugin

done
heading includes Attendance
description includes Student X
# Group and sort the output: 
group by filename
sort by due reverse 
sort by description 
```tasks
done
heading includes Attendance
description includes Student X
# Group and sort the output: 
group by filename
sort by due reverse 
sort by description 
```

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