Obsidian Dataview Query To Return Values Of Inline Fields In Nested Lists Under Tasks

I store metadata for tasks using inline fields (e.g. location:: 4802 Fifth Avenue) under a heading in a nested list. The purpose of this is so that this metadata folds neatly away in notes and so that tasks appear tidy in dataview queries. See below for an example use case of the header in a sublist:

This works very well for keeping dataview results appearing clean, except I cannot seem to get Obsidian Dataview Queries to consistently filter correctly based on inline field values that are stored in the nested list under the task.

For example, I am attempting to only return parent tasks that have sublists or subtasks where the value for inline field “cancelled” is not true.

I’ve noticed that if a single task is in a note, the dataview query works as expected. But, if the task is among several other tasks in a note, dataview does not seem to detect the inline field values of sublists.

To test, I wrote the following simple dataview query:

TASK 
WHERE cancelled = true

The result was “Dataview: No results to show for task query.” even though the field “cancelled” is clearly set to true. But, if I move the task to its own note, it appears in the query results.

I have tried several approaches such as using subtask.fieldname or FLATTEN but have had no success.

Is it possible to write a query to evaluate inline fields of task sublist or subtask items on a page with multiple tasks? e.g. WHERE sublist.fieldname != true?

My desired result is to search my entire vault for tasks and to only return parent tasks that have sublists or subtasks where the value for inline field “cancelled” is not true.

How does the markup for that image look like? What kind of source text do you use to produce that visual?

I’ve explored various options related to grouping information together, but the approach varies depending on the source text.

One thing though could be that you possibly need to start of with something like: TASK WHERE !parent to get the parent tasks only, and then extend from that to filter/process information in subtasks.

Another option to achieve the same is to use a inline field for the main text itself, like (desc:: Get with Mom on insurance information), and then do a FLATTEN desc as visual. You could then put whatever extra information you want into the task itself, and not bother with subtasks/lists and so on.

Thanks for the assist. Here’s the markdown:

- [ ] Get with Mom on insurance information
- ##### Metadata
[scheduled:: ]  [due:: ]  [length:: 1h0m]  [date_created:: 2023-04-26 03:05:26]  [source:: ]  [affordability:: 0]  [importance:: 0]  [urgency:: 0]  [context:: ]  [ondeck:: false] [top6:: false]  [cancelled:: true]  tags: 
- [ ] Get with Dad on insurance information [scheduled:: ]  [due:: ]  [length:: 1h0m]  [date_created:: 2023-04-26 03:18:03]  [affordability:: 0]  [importance:: 0]  [urgency:: 0]  [context:: ]  [ondeck:: false]  [top6:: false]  [cancelled:: true]  tags:  #SM-N986U1,

I included the second task because as I mentioned the inconsistent filtering on sublist inline fields happens when multiple tasks are in the same note. You will also notice that the second task is formatted differently which the query seems to works fine with.

I tried the FLATTEN trick and it works well in Dataview but does not work well with the checklist plugin. (I use both the checklist and tasks plugin). Here’s how it appears in the sidebar.

2023-12-12_221940_TLF-HV1DVZ2

Accomodating both the dataview and checklist plugin could be tricky. To make tasks look nice in checklist one could do something like:

- [ ] Get with Mom on insurance information
	 - [scheduled:: ]  [due:: ]  [length:: 1h0m]  [date_created:: 2023-04-26 03:05:26]  [source:: ]  [affordability:: 0]  [importance:: 0]  [urgency:: 0]  [context:: ]  [ondeck:: false] [top6:: false]  [cancelled:: true]  tags: 
- [ ] Get with Dad on insurance information
	- [scheduled:: ]  [due:: ]  [length:: 1h0m]  [date_created:: 2023-04-26 03:18:03]  [affordability:: 0]  [importance:: 0]  [urgency:: 0]  [context:: ]  [ondeck:: true]  [top6:: false]  [cancelled:: true]  tags:  #SM-N986U1

But then you would need to do children[0].ondeck to check the ondeck attribute of that particular task. Note how the metadata are indeed a sub-list item of the main task, and not a neighbor line with information like it was in your markup.

However, when querying these tasks through dataview the text is clean, but it does show the metadata on the next level, and I’m not sure if (or how) to hide sub-lists of a task. I tried doing FLATTEN list() as children to kind of eliminate the children of that task, but that and some other attempts failed.


So going back to the drawing board I’ve got a few questions, and that is why do you use the checklist plugin? Wouldn’t a dataview query in a noted (pinned to a side panel) work the same? Or put another way; What do the checklist plugin do, which is not easily replicated by dataview ?

1 Like

Thanks for this. I will try this momentarily.

In short, search. The checklist plugin in the sidebar allows me to quickly search for tasks (by task text or tags) and open the corresponding note. I use it a lot.