If ignoring being able to interact with the tasks, and not removing duplicate folder or name information, maybe something like this beast would suffice for your needs?
```dataview
TABLE WITHOUT ID
min(rows.file.folder) as Folder,
min(rows.file.link) as File,
sum(rows.item.tags) as Tags,
map(rows.item, (r) => "[" + r.status + "] " + r.text) as Tasks
FLATTEN file.tasks as item
GROUP BY file.folder + file.name + item.tags
```
```dataview
TABLE WITHOUT ID
min(rows.file.folder) as Folder,
min(rows.file.link) as File,
sum(rows.item.tags) as Tags,
map(rows.item, (r) => "[" + r.status + "] " + r.text) as Tasks
FLATTEN file.tasks as item
GROUP BY file.folder
```
But in this particular statement, I am not able to filter only the not-completed tasks.
I had tried all the following WHERE clauses:
WHERE rows.item.status != "completed"
WHERE !completed
WHERE item. Task and contains(list(" ", "/", "-", "x"), item.status)
WHERE row.item.status != "x"
FLATTEN length(filter(sum(rows.file.tasks.status), (t) => t = " " or t = "/")) as Incomplete
WHERE rows.file.task.status != "x"
FLATTEN lenght(filter(file.tasks.status != "x")) as item
Any ideas how to filter only the incomplete tasks?
Thanks!
The #personal tag is here related to the page, and are as such not connected to either of the tasks. And there is no easy way to connect it these tasks beside it being attached to all tasks on that note.
So you could move it to the tasks, and thusly connect it. It’s all so doable, but it’ll complicate other parts of your query, to change “#personal” to something like “## personal” (aka a header) and then do some trickery to connect the tasks to that section.
Filter out certain statuses
This line lists the various items with all variants of statuses. One could apply some logic to it, like the below:
I wouldn’t do that though, since if this filter out all the items, you don’t really want that row to show up in the first place. So a better option is to do the filter after the GROUP BY clause, and add another WHERE clause.
Then we end up with something like this:
```dataview
TABLE WITHOUT ID
min(rows.file.folder) as Folder,
min(rows.file.link) as File,
sum(rows.item.tags) as Tags,
map(items, (r) => "[" + r.status + "] " + r.text) as Tasks
FLATTEN file.tasks as item
GROUP BY file.folder + file.name + item.tags
FLATTEN array( filter( rows.item, (r) => r.status != "x" ) ) as items
WHERE items
```
There are three changes made in this variant of the query:
FLATTEN array(filter( rows.item, (r) => r.status != "x" ) ) as items, which is the crucial part, where we filter out only the tasks we want to list. Here you can exchange the r.status != "x" with almost any of the WHERE clauses you tried. Just make sure it returns a positive value if you want to keep that task.
Then the array( filter ( ... ) ) as items will make sure to return this as a new list of the wanted tasks
That is then used for displaying purposes in the map( items, ... ) row above the first flatten (which used to be map( rows.itme, ... )
And it’s used in the last line WHERE items, where it verifies that we actually have some tasks we want to show for this combination of folder, file and tag.
It took a little bit of fiddling to get it to be this variant, and I’ve written quite a few queries lately, so don’t be dismissed by not being able to write such a query in one go.
The trick to building queries like this is to write multiple queries, where you start out listing all of the information you might want in the end result, and then write intermediate queries where you narrow down your data set, and start grouping/filtering/flattening according to your needs.
And of course, if you’re stuck at some point ask for guidance with good descriptions of your data set and the current query and what you ideally would like out of it. In due time, you’ll get to write the queries you want more and more on your own.