Dataview "Looped"/Nested Tables

What I want to achieve

I have people for each of them there is an own note
I use them in Tasks to say [[X Person]] has to do XYZ
I can use dataview to show me in the persons page all tasks that have their own name in it.
What i would like to achieve is see all tasks that have a person in it that belongs to a specific group or team.
ie. lets say i go to the page of the accounting team.
i would see all tasks there that have people in it that a part of the accounting team.
Which i can either achieve by linking the team in the persons page, or i can add a tag or metadata. I would do what you recommend me makes the most sense.
Thanks in advance for all the help

For anyone to be able to help you, we would need some example data, both of what your input looks like, and what your expected output should look like. Some of your attempts at this, in the form of queries would also be beneficial your end goal.

@holroy thanks for the input
in each team i can find all the linked people with:

LIST FROM ([[#]]) OR outgoing([[#]]) 

in each of those people i find the tasks that have them in it via:

Where contains(text,

I want to merge them all together in the team that it says about:

where text in (LIST FROM ([[#]]) OR outgoing([[#]]) 

What if a person belongs to multiple teams? How do you think to separate their task with one team from tasks with another team?

Is that [[#]] referring to something like [[Accounting team]] ?

if its belonging to multiple teams the task would show up in both which is fine. I just want to see all the open tasks of a specific team of mine when i have catch ups with them.
Yes correct [[#]] refers to teams like [[Accounting_Team]]

So basically we’ve got a task like the following:

- [ ] [John Doe] needs to get a name

And in his page, it says something related to:

John is part of the [[Accounting team]]

Which could also be mentioned in the [[Jane Smith]]s page, and you would like to see all tasks of John and Jane. That’s a brain teaser, for sure…

Theoretically it should be something like:

  • Tasks having an outlink to a person, which at the same time is an inlink to the team, or …
  • Tasks having an outlink to a person, where the person has a team-tag with the given team

Hmm… I need to ponder on that for a little while. Hopefully I’ll come back with a suggestion. Will take some time to build up a test case, and get the syntax correct for this one. So if anyone see the light, feel free to contribute.

absolutely correct
i tried some stuff as well but i couldn’t find an option.
In SQL it would just be defining the first list, storing it as an array and that adding a filter seeing if that value is in said array.
NO clue if that can be achieved in Dataview but it would be great as I think could also use the same logic for other “multi-level” queries

It was actually easier than I thought, when I just got some test data going. I’ve opted to denote team belonging with team:: [[Account team]] or similar in the main text of a persons note. The advantage of this versus in the frontmatter, is that if you rename a team, Obsidian will also change this automatically.

Then to help me build the case, I made up some persons and teams, and generated some tasks. John and Jane belong to the Account team, and Hupert belongs to the homeless guys. So I’ve got these tasks to work with:

In order to find the correct Tasks query, I usually go via a Table query, in this case the final variant of this became:

TABLE WITHOUT ID item.text, person,
FLATTEN file.lists as item
FLATTEN item.outlinks as person
WHERE item.task AND item.outlinks AND

This went through some stages, where I added/removed/changed various bits and pieces to the columns. The FLATTEN file.lists as item splits up all lists items (which could be task or not) into seperate item rows. Now checking for item.task limits the list to only tasks. In a TASK query this already done for you, but this is how you mimic a task list in a table query.

Next step was to only pick tasks which linked to one or more persons. This is stored in the outlinks of each task, so we need yet again to flatten into handling each one separately, hence the FLATTEN item.outlinks as person, and we only want these tasks so I added and to the WHERE clause (and as a column to debug). At this point the result of my query was the following:

And now I could see the end goal, as all that was needed was to limit to only the team I wanted to get the tasks for. So I added that, and transformed the table query, into a task query, and ended up with this query:

FLATTEN outlinks as person
WHERE AND = [[]]

Notice how since we’re now doing the pure task query, I don’t need the item.outlinks and that FLATTEN into items. This query now returns:


And that should be all tasks related to the Account team (or whatever team you put that query into).

PS! Sorry about any typos like recipt… Can’t be bothered to redo the images just now. :smiley:

1 Like

If you get a task which lists two persons belonging to the same team, then this query would generate two tasks in the summary option. From a pedagogical point of view, I kind of like this solution, but to avoid that feature/issue with your query, you could change it into:

WHERE any(outlinks, (link) => = [[]])

This selects any matches from the tasks outlinks list, where we map each of those link’s into an equality match ` = [[]]``, and this match is true (for one or more entries).

1 Like

awesome its so clean :slight_smile: beautiful thank you so much

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