Dataview Table - Display only first uncomplete task on a page

What I’m trying to do

I would like to use dataview to build a table (not a dataview TASK view) that includes a column with the note (the first column, obviously) and a column with the text of the first uncomplete task that appears on that page.

Many thanks in advance!

You can explore something like this:

TABLE rows.myTasks.text[0] AS "My first uncompleted task in the note"
FROM "your/folder/path"
WHERE file.tasks
FLATTEN file.tasks AS myTasks
WHERE !myTasks.completed
GROUP BY file.link AS "My note"

(but I would have preferred to see one first query attempt… to it doesn’t look like a solution à la carte, but a way to learning.)

1 Like

Many thanks for this! And apologies for not including a query attempt. Will do that next time.

So, I’ve played with what you’ve suggested (while also trying to introduce some changes), but it seems I’m still a bit confused. Here’s what I currently have:

TABLE Without ID
	rows.myTasks.text[0] AS Task,
	file.link AS Page, 
	Project
FROM -"Templates"
WHERE file.tasks 
FLATTEN file.tasks AS myTasks 
WHERE !myTasks.completed 
GROUP BY file.link

The problem I’m running into now is that the file.link and the Project (a piece of metadata in each note) are not showing up. I suspect has something to do with the GROUP BY line, but I’m not entirely sure…

That is the problem of just give you a solution without context and previous attempts.
In the case you’ve no idea of the consequences of the command “GROUP BY” in the query.

The code has a order of commands, and some commands have consequences in the data structure on the background. The final reflection of that process is in the initial lines (the lines that define the columns, the last thing to consider in a table query).

The command GROUP BY something produces two things: the key (the something) and rows (the other things that now are nested in each group). That’s why we add the prefix rows. in rows.myTasks.text. I.e., generically, after the group command you need to add the prefix rows. to target the previous fields.

So, if you try rows.file.link and rows.Project maybe you achieve the wanted solution. (but because you group by file.link, you don’t need to add the prefix… you can use key AS Page)

But we are discussing a type of commands that require some previous learning in the way the metadata is structured in the raw and what happens after commands as GROUP BY and FLATTEN.

Extra: to see the structure of the metadata in specific file use this inline js query (activate js queries in settings > dataview) in that file:

`$=dv.span(dv.current())`
3 Likes

That did the trick! Many thanks for your help. I’ll be sure to provide more context next time so as not to add confusion!

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