List pages that have uncompleted tasks NOT tagged as #next

My Obsidian grew bigger this year and I cannot keep track of everything manually anymore. I installed the dataview plugin and started fiddling with some filters, however, I’ve hit a roadblock and that’s why I’m asking here!

So, I’m trying to get a list of files I need to review. In my project management system, a project needs to have at least one uncompleted task marked as next, otherwise either the project is blocked or it’s completed and moved elsewhere.

This is the query I have so far, the best I could do

TASK 
FROM "4. Projects/1. Active" 
WHERE !completed AND !contains(tags, "#next") 
GROUP BY file.link

However, this doesn’t work. It just shows files with open tasks (and all the tasks in them), and I cannot find a way to exclude them if there’s an uncompleted task tagged as #next, nor to show only the file link.

Any idea?

I started fiddling with dataviewjs, but it’s too difficult for me :grimacing:

Edit: I started working on another filter for my system, and hit another unknown

Basically, each project in that folder also needs to be linked to one or more AREAS thanks to a areas:: inline field.

I would like to also have a list of AREAS (stored in “2. Areas/1. Active”) that DO NOT have a project linking to them, for maintenance. I tried checking file.inlinks but I must be doing something wrong. Any idea for this too? Didn’t want to open a new topic :grimacing: I am already asking too much stuff!

Have you tried the query mechanism of Obsidian Tasks?
You will not be able to filter based on a page, but if a task resolution works for you, this is easily to accomplish.

Isn’t this what I’m doing with that query? That one returns ALL the tasks grouped by ALL the documents in that folder that are NOT tagged #next, including the ones in a document that also has an uncompleted task tagged #next (that task is, of course, not showing)

However, I’m interested in retrieving just links to the pages that do not contain an uncompleted task tagged #next. If this task filter could exclude tasks from a document with an uncompleted task tagged #next, I would be partially satisfied. But this result is not useful for me, sadly

I don’t know if I managed to explain myself :smiley:

Topic

Summary
  • How to show only the file link that does not contain an uncompleted task tagged with #next?
  • PS.However, I’d like to exclude from the list any file that actually has at least one (uncompleted task marked as #next)

Test

Summary
  • dataview: v0.5.41

Input

Summary

dictionary files

  • Location: “100_Project/02_dataview/Q13_Tasks/Q13_test_data”

03

  • filename : dic_19980301
---
Date: 1998-03-01
---

## input
### main tasks
- [ ] 1998-03-01 add this feature_a #Test/d01 [[Note P]] , [[Note Q]]
- [ ] 1998-03-02 add this feature_b #Test/d02  [[Note P]]
- [ ] 1998-03-03 add this feature_c [[Note Q]]
- [ ] 1998-03-04 add this feature_d #Test/d04
- [x] 1998-03-05 add this feature_e #Test/d05 [[Note Q]]
- [ ] 1998-03-06 add this feature_f #Test/d06
- [ ] 1998-73-07 add this feature_g #Test/d07
- [ ] 1998-03-08 add this feature_h [[Note P]] , [[Note Q]]
- [ ] 1998-03-09 add this feature_i 
- [ ] 1998-03-10 add this feature_j  
- [ ] It is finished!



04

  • filename : dic_19980401
---
Date: 1998-04-01
---

## input
### main tasks
- [ ] 1998-04-01 add this feature_a #Test/d01 [[Note P]] , [[Note Q]]
- [ ] 1998-04-02 add this feature_b #Test/d02  [[Note P]]
- [ ] 1998-04-03 add this feature_c [[Note Q]]
- [ ] 1998-04-04 add this feature_d #Test/d04
- [x] 1998-04-05 add this feature_e #Test/d05 [[Note Q]]
- [ ] 1998-04-06 add this feature_f #Test/d06
- [ ] 1998-74-07 add this feature_g #Test/d07
- [ ] 1998-04-08 add this feature_h [[Note P]] , [[Note Q]]
- [ ] 1998-04-09 add this feature_i 
- [ ] 1998-04-10 add this feature_j 
- [ ] It is finished!




05_excluded

  • filename : dic_19980501
---
Date: 1998-05-01
---

## input
### main tasks
- [ ] 1998-05-01 add this feature_a #Test/d01 [[Note P]] , [[Note Q]]
- [ ] 1998-05-02 add this feature_b #Test/d02  [[Note P]]
- [ ] 1998-05-03 add this feature_c  [[Note Q]]
- [ ] 1998-05-04 add this feature_d #Test/d04
- [x] 1998-05-05 add this feature_e  #Test/d05 [[Note Q]]
- [ ] 1998-05-06 add this feature_f  #Test/d06
- [ ] 1998-75-07 add this feature_g #Test/d07
- [ ] 1998-05-08 add this feature_h [[Note P]] , [[Note Q]]
- [ ] 1998-05-09 add this feature_i 
- [ ] 1998-05-10 add this feature_j 
- [ ] It is finished! #next




06_excluded

  • filename : dic_19980601
---
Date: 1998-06-01
---

## input
### main tasks
- [ ] 1998-06-01 add this feature_a #Test/d01 [[Note P]] , [[Note Q]]
- [ ] 1998-06-02 add this feature_b #Test/d02  [[Note P]]
- [ ] 1998-06-03 add this feature_c  [[Note Q]]
- [ ] 1998-06-04 add this feature_d #Test/d04
- [x] 1998-06-05 add this feature_e  #Test/d05 [[Note Q]]
- [ ] 1998-06-06 add this feature_f  #Test/d06
- [ ] 1998-76-07 add this feature_g #Test/d07
- [ ] 1998-06-08 add this feature_h [[Note P]] , [[Note Q]]
- [ ] 1998-06-09 add this feature_i 
- [ ] 1998-06-10 add this feature_j  #next
- [ ] It is finished! #next



07_excluded

  • filename : dic_19980701
---
Date: 1998-07-01
---

## input
### main tasks




DQL10_flatten_fLists_and_display_fLinks_only

Summary

Main DQL

Code Name Data type Group By Purposes Remark
DQL10_flatten_fLists_and_display_fLinks_only task items yes 1.To flatten file.lists
2.To fiter by uncompleted task items
3.To groupBy file.link as G1
4.To gather uncompleted task items that aren’t tagged with #next
5.To display each G1 as rows.file.link[0]

Code DQL10_flatten_fLists_and_display_fLinks_only

Summary_code
title: DQL10_flatten_fLists_and_display_fLinks_only =>1.To flatten file.lists 2.To fiter by uncompleted task items 3.To groupBy file.link as G1  4.To gather uncompleted task items that aren't tagged with \#next 5.To display each G1 as rows.file.link[0]
collapse: close
icon: 
color: 
```dataview
LIST WITHOUT ID 
     rows.file.link[0]
FROM "100_Project/02_dataview/Q13_Tasks/Q13_test_data"
FLATTEN file.lists AS L
WHERE L.task AND !L.completed
GROUP BY file.link AS G1
WHERE !filter(rows.L.tags,(e) => contains(e, "#next"))

```

Screenshots(DQL10)


DVJS10_flatten_fLists_and_display_fLinks_only

Summary

Main DVJS

Code Name Data type Group By Purposes Remark
DVJS10_flatten_fLists_and_display_fLinks_only task items yes 1.To groupBy page.file.link as G1 (G1=group.rows)
2.To flatten page.file.lists
3.To gather uncompleted task items that aren’t tagged #next
4.To display each G1 as file.link

Code DVJS10_flatten_fLists_and_display_fLinks_only

Summary_code
title: DVJS10_flatten_fLists_and_display_fLinks_only => 1.To groupBy page.file.link as G1 (G1=group.rows) 2.To flatten page.file.lists 3.To gather uncompleted task items that aren't tagged \#next 4.To display each G1 as file.link
collapse: close
icon: 
color: 
```dataviewjs
// M11. define pages: gather all relevant pages
// #####################################################################
let pages = dv
    .pages('"100_Project/02_dataview/Q13_Tasks/Q13_test_data"');


// M21. define groups:
// To groupBy page.file.link AS G1 (G1=group.rows)
// #####################################################################
let groups = pages
    .groupBy((page) => page.file.link);
    //.sort((group) => group.key, "desc");


// M31. output groups:
// #####################################################################
for (let group of groups) {
    
    // M31.FR09 define b_filtered_lists : 
    // added at 2022-09-20 16:00
    // FLATTEN page.file.lists and gather them: 
    // get uncompleted task items that are tagged with #next
    // However, I’d like to exclude from the list any file that actually has at least one (uncompleted task marked as \#next)
    // #####################################################################
    let b_filtered_lists = group.rows
            .flatMap((page) => page.file.lists)
            .where(
                (L) => L.task &&
                       !L.completed &&
                       dv.func.contains(L.tags, "#next")        
            );
    
    
    // M31.FR11 check b_filtered_lists.length : 
    // added at 2022-09-20 16:00
    // #####################################################################
    if (b_filtered_lists.length !== 0){
        continue;
    }   
    
    
    // M31.FR13 define a_filtered_lists:
    // FLATTEN page.file.lists and gather them: 
    // get uncompleted task items that aren't tagged with #next
    // #####################################################################
    let a_filtered_lists = group.rows
        .flatMap((page) => page.file.lists)
        .where(
            (L) => L.task &&
                   !L.completed &&
                   !dv.func.contains(L.tags, "#next")        
        );


    // M31.FR15 check a_filtered_lists.length :
    // #####################################################################
    if (a_filtered_lists.length === 0){
        continue;
    }
    
        
    // M31.FR21 output page.file.link :
    // #####################################################################
    //dv.header(3, group.key);
    dv.el("li", group.key);
    
    
    // M31.FR23 output a_filtered_lists.text: [with the desired structure]
    // #####################################################################
    //dv.taskList(a_filtered_lists, false); 
}


```

Screenshots(DVJS10)


1 Like

Wow! This is amazing. I think I get it, I didn’t know you could do this sort of advanced stuff with dataviewjs :open_mouth:

Do you have any suggestions for the formatting of the outputs? Right now it seems the results are headings, and they make my list incredibly big :see_no_evil: I don’t understand where the actual displaying of the list is happening in this code nor how to change it. Marking it as the solution anyways

Edit: I found dv.header() and tried changing it to dv.list()… the result is empty now :grimacing:

1 Like

I managed to make it look nicer by changing the dv.header() line to dv.el("li", group.key);

1 Like

Thanks for your clever and useful suggestion.
The dv.header() line is replaced with dv.el("li", group.key) based on your answer.

1 Like

Anyways, that was really impressive. I’ve been able to create another two complex filters now that I know I can do such complex operations with objects and loops :open_mouth:

1 Like

Actually, I have a problem, and maybe it’s my fault for not having explained myself correctly, not sure.

Your filter returns ALL notes that have ANY uncompleted tasks not marked as #next. However, I’d like to exclude from the list any file that actually has at least one (uncompleted task marked as #next). In my system, if a project has at least one nextaction, it doesn’t need review. Any idea how to do so?

1 Like

Edit: I tried a second filtering but I’m not sure I understand how it works, because it doesn’t :see_no_evil:

let b_filtered_lists = group.rows
        .flatMap((page) => page.file.lists)
        .where(
            (L) => L.task &&
                   !L.completed &&
                   dv.func.contains(L.tags, "#next")        
        )

if (a_filtered_lists.length === 0 && b_filtered_lists != 0){
continue;
}
1 Like
  • Many thanks.
  • The DVJS10 is updated.
  • The DQL10 is added.
  • You could try it again.

I think the Dataview way to do this is:

TASK
FROM “4. Projects/1. Active” AND -#next
WHERE !completed
GROUP BY file.link

EDIT: Missed the negation of #next

Oh, I see, you don’t want to see the page at all if there’s any task tagged #next. Is there a reason you don’t just pull all files without a #next anywhere in the file (from that directory)? Are you using #next in one way when it’s used with tasks and another way outside of tasks? If not, just search for untagged files.

LIST
FROM “4. Projects/1. Active” AND -#next