In a job note there are `Person::` field and `Department::` field. In a person note there is `Department::` field. How to query a table of departments and its personnel without getting the job notes?

I have 3 folder (or 3 types of notes): Job, Person, Department. In a job note there are Person:: field and Department:: field to other notes of other types. In a person note there is Department:: field.

image

In the homepage I want to query a table of all departments and its personnel. In a simple backward query I can use

Table filter(file.inlinks, (p) => contains(p.department, file.link))
from "Department" 

However this will clutter with the job notes. I need to further filter the inlinks to get only the person ones. How can I do that? It seems that I cannot use nested filter like this:

filter(filter(file.inlinks, (f) => contains(file.folder, "Person")), (p) => contains(p.department, file.link))

because the file in the second filter should not be a department note, but a person one. But in this query it is.

I’ve looked at the Dataview Example Vault but it doesn’t seem to have something like this. If I get the answer I will add to it.

I know the simplest solution is to use different keys for department in job and person. However I want to push my DV skills to its limit :stuck_out_tongue:

Can you use the fact that there is no Person field in “Person” note to separate “Job” and “Person”?
e.g. to get rid of the “Job” notes in your first query example, does the following work?

TABLE filter(file.inlinks, (p) => !p.person AND contains(p.department, file.link))
FROM "Department" 
1 Like

This is a brilliant idea. However there are some jobs that don’t have person yet, so DV counts them as not having that field too. Is there a way to exclude them as well?

1 Like

Is there anything else that makes the Job and Person notes different? Title? Folder? Other content? Be creative!

1 Like

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