DataView Tasks: Pull incomplete tasks backlinked to notes with specific tag in header

What I’m trying to do

Within my daily notes, I use #log/sprint to capture info relating to various projects and parts. For example, on 7/23/2025 I might log:

  • [u] #log/sprint on #project/ExampleProject/part
    - Released Revision A of [[pn 11111]] to production
    - Update description of [[pn 22222]]
    - Update title of [[pn 333333]]

Then, on my [[pn 11111]], [[pn 22222]], or [[pn 33333]] note pages, I see every task I’ve ever logged that links to that specific page. These pages are then tagged in frontmatter with #project/ExampleProject/part indicating they are parts that belong to ExampleProject

TASK
WHERE icontains(text, this.file.name)

Easy, no issues so far.

On my [[ExampleProject]] page, I see all sprints that have been tagged with #project/ExampleProject. Again, no issue here.

TASK
WHERE icontains(text, "#log/sprint")
AND (icontains(text, this.file.name) OR icontains(text, "#project/ExampleProject") )

However, I’d like a page in which I see all the incomplete tasks to any page with #project/ExampleProject/part in the frontmatter. Expected results would be:

###Example Project Part Issue Tracking

Incomplete tasks of parts with #project/ExampleProject/part in frontmatter
pn 22222
- Update description of [[pn 22222]]
pn33333
- Update title of [[pn 333333]]

Things I have tried

Various google searched, combination of WHERE + FROM queries.

Thank you in advance

Things I have tried

claremacrae’s solution posted nov 23, 2022
“Possible to query tasks only from files with certain tags [in frontmatter]? #442

I’m trying my best to understand the dataviewJS component, but its my first foray into JS.

```dataviewjs
const tag = '#project/ExampleProject/part'
const matching_files = dv.pagePaths(tag)
if ( matching_files.length > 0 ) {
    const query = `
        not done
        (path includes ${matching_files.join(') OR (path includes ')})

        # you can add any number of extra Tasks instructions, for example:
        group by path
`;

    dv.paragraph('```tasks\n' + query + '\n```');
} else {
    const message = `No files found with tag ${tag}`
    dv.paragraph(message)
}

I’m seeing 2 issues with this solution:

  1. This returns incorrect tasks from the following daily note. Even though I’m querying #project/ExampleProject/part, its also returning the task under #project/OtherProject because its in the same daily note file.
- [u] #log/sprint on #project/ExampleProject/part 
	- [x] Send 3x ECOs out for digital review today
	- [ ] Must clean up [[00011]]. 
- [u] #log/sprint on #project/OtherProject
	- [ ] Need ECO for [[Apollo]] artwork update on battery pack
  1. The results are grouped by note path when I’d like them grouped by linked mention.

Is this what you’re going for?

```dataview
TASK
WHERE !completed AND contains(outlinks.file.tags, "project/ExampleProject/part")
GROUP BY string(outlinks)
```
1 Like

Thats very close, thank you! However I’m running into the following edge case. I tag people and companies using [[@people]] or [[@company]].

When I have 2 outlinks in the same task, for example

#log/task on #exampleProject
- [ ] Send pn [[11111]] to company [[@exampleCompany]]

then the dataquery you suggested will show:

11111, @exampleCompany
- [ ] Send pn [[11111]] to compan [[@exampleCompany]]

However, ideally I would prefer these broken up into individual header consisting of 1 outlink.

11111
- [ ] Send pn [[11111]] to compan [[@exampleCompany]]
@exampleCompany
- [ ] Send pn [[11111]] to compan [[@exampleCompany]]

Any advice?

FLATTEN outlinks

Seemed to have done the trick.

Now the only edge case remaining is that notes are seperated by their file name and alias, when I’d like them combined into 1 header. Do you know have any solution?

TASK
WHERE !completed AND contains(outlinks.file.tags, "project/ExampleProject/part")
FLATTEN outlinks
GROUP BY string(outlinks)
SORT filename DESC
1 Like

I think you’re saying that when one task item has [[pn 11111|alias1]] and another has [[pn 11111]] or a different display name, you get separate groups for the same note. Let me know if you meant something else.

Does removing the string transformation from GROUP BY fix that?

```dataview
TASK
WHERE !completed AND contains(outlinks.file.tags, "project/ExampleProject/part")
FLATTEN outlinks
GROUP BY outlinks
SORT filename DESC
```
1 Like

You are correct and this fully captures the intention what I’m trying to accomplish here.

Thanks so much!

1 Like

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