Some help with Dataview for "unified" tasks & notes on both desktop and mobile?

I didn’t mean one unified query for both, but that I have two queries, one under the other. The first shows a list of tasks, the second a list of notes (some of them including those tasks). Both filtering them according to a) if they aren’t marked completed/done, and b) if they include a parameter (or not).

Here’s an example of such a section:

TASK
FROM #tasks AND #people/mary
WHERE !completed
SORT Due
LIST
FROM #people/mary
WHERE !completed AND (!due = "" OR !priority = "")
SORT Due

All task-related notes have "Completed: ", as well as other parameters like “Tags:”, “Status:”, “Due:”, etc., in the YAML front matter. However, I’m also using inline meta for each respective task. So, I can query a bundle of notes to get lists that either don’t have “Completed: Yes” in the YAML front matter, or contain tasks that aren’t marked completed. Here’s an example for notes with “Priority: High” in the front matter OR containing tasks marked with “[[Priority: High]]” inline:

LIST
WHERE (!completed OR (Completed="No") OR (Completed="") AND !(Completed="Yes")) AND (Priority = "High") OR (Priority = "high") OR (Priority = "hi") OR (Priority = "3")

Although I don’t see an error in my syntax, it borks. Here’s an example of the front matter setup in a note:

---
Tags: [ people/mary ]
Type:
Status:
Time:
Due:
Priority: 
Completed:
Notes:
---

The way I’m understanding how dataview works, the above should show up with the query below, but it doesn’t:

List
FROM #people/mary
WHERE (!completed OR (Completed="No") OR (Completed="") AND !(Completed="Yes")) AND (priority="" OR Priority="" OR due="" OR Due="")
SORT Due

Although the particular note doesn’t contain any tasks (so that maybe some inline meta was the source of the problem), and all values apart from the person’s tag are blank, it doesn’t show up with the List query above. The query itself is supposed to show all notes OR notes containing incomplete tasks with no priority or due date set.

As you might have noticed, some rules repeat, since I’ve realized YAML is case-sensitive - at least in Obsidian. I want my “rules” to work both if I set a date as “due” and “Due” in a note’s YAML.

It’s been hours I’m fumbling with this and I’m pretty sure it’s the stupidest mistake possible, but for the life of me I can’t pinpoint the problem.

You say that you didn’t mean one unified query, but I see many overlay in your queries.
For example:

LIST
FROM #people/mary
WHERE !completed AND (!due = "" OR !priority = "")
SORT Due

This is not a TASK query, but !completed it’s a task data, not a page/note data!
Considering the case-sensitive for your page fields, I deduce that due and priority are, in the same way, tasks data, not page data.

My point is: in the page level you can’t overlay ‘conditions’ with page data and task data. If you querying at page level and want go to tasks level, may you need to call file.tasks, but I’m not sure what can be done with that. At page level you can ask WHERE none(file.tasks.completed) or WHERE any(file.tasks.completed), etc.

No, the bit you quoted is actually supposed to rely on page front matter. See the front matter of the notes I’ve posted in my previous reply. Sorry for repeating myself, but it includes values for:

  • Tags
  • Type
  • Status
  • Time
  • Due
  • Priority
  • Completed
  • Notes

My goal with my-query-that-doesn’t-work is to use ONE of those values, a particular tag, as the source for a list of notes. So, if it’s “people/mary”, it should show all notes that include that tag. Then, to filter down those notes and show only those that don’t have a value set in either “Completed”, “Due”, or “Priority”. Or, in the case of completed, also skip those that have a “Yes” value.

However, it doesn’t work. Here’s an alternative that according to what you said should work, since it doesn’t contain anything task-specific:

List
FROM #people/nitsa
WHERE (Completed="No" OR Completed="" AND !Completed="Yes") AND (priority="" OR Priority="" OR due="" OR Due="")
SORT Due

I must stress that Completed, Priority, and Due exist in the notes front matter.

I should also note that my use of “!completed” was because “that’s the way I know you can check if a value is set”, and saw some such examples when searching for solutions. I’m no programmer, but I’ve been banging on keyboards for over 30 years, and I’m also building scripts with AHK. AFAIK, when you’re using an exclamation mark in front of a parameter, in many programming languages it’s the equivalent of checking if the value isn’t set - that was my intention. On the opposite hand, if you use just the value it means it does exist.

Note that I don’t mention how I have experience in tech to prove I’m somehow right or better than others, for I’m not. Obviously. I wouldn’t be asking here if I (believed I) was. I’m just saying that I was under the impression “it works this way”, and I’m almost sure I saw similar queries in other threads here. That’s why I can’t wrap my head around why this query doesn’t work in my case, and can’t seem to be able to find a solution :frowning: .

This is a kind of “circular” dialog… As mentioned in previous posts, as much as I know, yaml fields are case-sensitive. So, “completed”, “due”, “priority” are not page fields from YOUR frontmatter! Your frontmatter fields are: “Completed”, “Due”, “Priority”

(A suggestion: to avoid confusions choose field names slightly different from pages and for tasks?)

Your query:

```dataview
List
FROM #people/nitsa
WHERE (Completed="No" OR Completed="" AND !Completed="Yes") AND (priority="" OR Priority="" OR due="" OR Due="")
SORT Due
```

priority, due are not fields from pages! (Need the uppercase). But as you use equal fields names in tasks, I deduce that they belong to the tasks (sorry if it’s a wrong deduction).

Considering what I have said in previous posts, why not only this:

```dataview
LIST
FROM #people/nitsa
WHERE (Completed = "No" OR !Completed) AND (!Priority OR !Due)
SORT Due ASC
```
  1. (Completed = "No" OR !Completed) means where the field “Completed” has the string “No” OR is empty (i.e., !(not)Completed… no necessary write “” or other similar)
  2. (!Priority OR !Due) means without any value in “Priority” or “Due” fields.

(Just to clarify: I’m not a programmer, not a code guy, nothing related… just a simple Obsidian user with some particular interest in Dataview plugin. What I know about Dataview is restricted by the experience and knowledge acquired with it - not by external influences with others ‘languages’, javascript, etc. - an unknown world for me).

EDIT
If your fields in yaml frontmatter are not equals in all your notes (“Due” vs “due”), my first suggestion is: uniformize them. If not possible, then you can add them to the query (i.e. !Priority OR !priority OR !Due OR !due). But avoid to use equal names in tasks inline fields.

Nope, still doesn’t work as it should. I copy-pasted your suggestion exactly as you posted it in a new section. I have a note with the following front matter:

Tags: [ people/nitsa ]
Type:
Status:
Time:
Due:
Priority: 
Completed:
Notes:

As soon as I mark the page completed with “Completed: Yes”, it doesn’t show up in the list, as it should.

To be crystal-clear, the above is precisely the front matter in a note. I’m using the query you provided:

LIST
FROM #people/nitsa
WHERE (Completed = "No" OR !Completed) AND (!Priority OR !Due)
SORT Due ASC

I’ve added values on each of those parameters to test them. NOT combinations as in Due and priority set at the same time, but each parameter tested on its own with the query you provided.

Due rule testing:

Empty: The page appears in the list.
Has proper value (date): The page appears in the list.
Has improper value (test, Batman, halp!): The page appears in the list.

Priority rule testing:

Empty: The page appears in the list.
Has proper value (High/Medium/Low): The page appears in the list.
Has improper value (Hello, test, helpme, 123): The page appears in the list.

Completed rule testing:

Empty: The page appears in the list.
Has value “No”: The page appears in the list.
Has improper value (Hello, test, Batman, whoa): The page DOESN’T appear.
Has value set to “Yes”: The page DOESN’T appear.

Does the same happen in your vault if you create a note with the front matter I’m using and try out your query? This is driving me crazy. I know your simplified and direct query should work. But it doesn’t.

I should add that I’ve also tried two tweaked versions of your query. The first one changed the “AND” to “OR”, since the tests above meant I’d be checking against each parameter. The query…:

LIST
FROM #people/nitsa
WHERE Completed="No" OR !Completed OR !Priority OR !Due
SORT Due ASC

…should show the particular note ONLY if:

  • Completed was set to “No”
  • Completed had no value/was unset.
  • Priority was unset.
  • Due was unset.

Am I right in that? Well, again, it-didn’t-work. And I must stress we’re talking about a note that contains only the front-matter I posted above, as well as a line or two of plaintext for testing. No other values/parameters. No tasks. Nothing.

Am I missing or “not getting” something?

This need to be clarified step by step…

1. AND, OR

From your previous post, with
WHERE (Completed="No" OR Completed="" AND !Completed="Yes") AND (priority="" OR Priority="" OR due="" OR Due="")
I deduce this: “I want all pages not completed AND at least one of the fields (priority OR due) empty”. I.e, !Completed AND (!Priority OR !Due).

But seems you want all pages with at least of one of the fields (“Completed”, “Due” or “Priority”) empty (or not completed). In this case you need to use OR in all conditions:

WHERE Completed = "No" OR !Completed OR !Priority OR !Due

This works?

EDIT: sorry, I read your post by parts… and I misreading your second query…

My tests:
image
image
image
image
image

Queries and results:
image
image

Nope. That’s the “tweaked” query I mentioned I’ve already tried. Again, to be crystal clear, I’ve further simplified everything. I have a note with NOTHING in it apart from the following front matter:

---
Tags: [ people/nitsa ]
Type:
Status:
Time:
Due: 2021-10-20
Priority: High
Completed: 
Notes:
---

I have this query in another note:

LIST
FROM #people/nitsa
WHERE Completed = "No" OR !Completed OR !Priority OR !Due
SORT Due ASC

And the note still appears among the results!

If I keep everything in the above front matter as-it-is, and change ONLY the value after completed to “Yes”, the note disappears, as it should.

However, it also disappears if this value is set to “test”, or “Batman”, or whatever else (when it shouldn’t, because adding the word “Batman” as a value doesn’t mean “the note should be marked as Completed: Yes”).

Deleting or adding any value to both Due and/or Priority doesn’t make any difference: the note still appears in the results, with or without values. It’s as if Priority and Due are fully ignored.

And yet, they aren’t, since I have a different query elsewhere specifically listing all pages marked with “Priority: High”, and the page is among them. As soon as I remove the “High” from “Priority”, the page disappears. It’s in this particular query where things go South and those values don’t seem to make any difference.

Head-scratcher, no?

This is not the right conclusion. “Completed” isn’t a file implicit field, it’s a field you create (as “Something:”, or “Magic:”). Dataview doesn’t deduce that by “Completed” you create a “Yes or No” field. Because that, “Batman”, “Ice”, etc. are accepted!

If you want to check all the valid implicit fields, create this query (to limit the results to one or two pages, create an specific tag in that pages:

```dataview
LIST file
FROM #test
```

Ah, okays, so, that clears this bit up.

HOWEVEEEEER (that was supposed to be dramatic)…

I just noticed that in your results this seems somewhat borked as well, except if - again - I’m missing something. In your “Note E” you do have a “Due” date set. And yet, the page appears among the results of the query, when it shouldn’t (because of the “!due” part of the query).

I’m starting to feel my brain paralyzing… :crazy_face:

We continue with some misunderstandings… (English isn’t my language…)
Let’s see…

WHERE Completed = "No" OR !Completed OR !Priority OR !Due

Again, this filter means “All pages that conform at least one of these conditions! AT LEAST ONE!”
My Note E accomplish two of the conditions: !Completed and !Priority

I think that AND and OR is not yet clarified!

A-HA!

Discovery time - but still, frustrating: thanks to your suggestion I saw the fields of this file. Prepare for more head-scratching. As I mentioned before, and sorry for repeating myself, we’re talking about a note which only contains the following:

---
Tags: [ people/nitsa ]
Type:
Status:
Time:
Due: 
Priority: 
Completed: 
Notes:
---

Wanna know what the fields detected are? I used your suggestion, tweaked as:

LIST file
FROM #people/nitsa 

The results?

* [Nitsa test note](app://obsidian.md/!Inbox/Nitsa%20test%20note.md):
  * path: !Inbox/Nitsa test note.md
  * folder: !Inbox
  * name: Nitsa test note
  * link: [Nitsa test note](app://obsidian.md/!Inbox/Nitsa%20test%20note.md)
  * outlinks:
  * inlinks:
  * etags:
    * [#people/nitsa](app://obsidian.md/index.html#people/nitsa)
  * tags:
    * [#people/nitsa](app://obsidian.md/index.html#people/nitsa)
    * [#people](app://obsidian.md/index.html#people)
  * aliases:
  * tasks:
  * ctime: 10:44 PM - October 09, 2021
  * cday: October 09, 2021
  * mtime: 3:52 AM - October 11, 2021
  * mday: October 11, 2021
  * size: 86
  * ext: md

So, basically, ALL of the front matter parameters are fully ignored?! Yes, I’ve tried adding values and keeping them empty, and I still see the above. The only thing that changes are the file attributes at the end (mtime, size).

AAaargh!

No! These are the implicit fields! Not the fields you create! This is the structure for “file.name”, “file.ctime”, “file.tasks”, etc.

Ah, I see. My bad. So, in your case, the notes appear since at least one condition is met. Yeah, I didn’t realize that.

English isn’t my primary language either, so this might be adding to my confusion. Let’s try it another way. I currently have this front matter in a note, and this is the only content in the note. Nothing else:

---
Tags: [ people/nitsa ]
Type:
Status:
Time: 2021-10-20
Due: 
Priority: High 
Completed: 
Notes:
---

I have this query in another note:

LIST
FROM #people/nitsa
WHERE Completed = "No" OR !Completed OR !Priority OR !Due
SORT Due ASC

The note appears in the results of the list. Should it be this way? If not, how should this rule be tweaked so that the note doesn’t appear if any of “Due”, “Priority”, or “Completed” are set?

As it is, the note appears even if, with the above setup, I delete the values after Due and Priority and leave them blank. Even if I add a Yes (no quotes, not that it makes any difference) as the value to Completed.

Ah, sorry, I didn’t know what “implicit fields” means, I thought it covered everything.

You need to read this documentation:
https://blacksmithgu.github.io/obsidian-dataview/data-annotation/#implicit-fields

Yes. The note accomplish two conditions: !Completed and !Due

FOUND IT!

…and yet, I can’t wrap my head around it.

I’ve added every possible iteration of the query in a single page for testing. Then, I started fooling around with the values to see what would trigger each query. The query that works if ANY of those values is populated is:

LIST
FROM #people/nitsa
WHERE !Due AND !due AND !Priority AND !priority AND !Completed AND !completed
SORT Due ASC

I never thought this was correct, or would work, because “AND” should mean “if THIS condition is met AND this OTHER condition is met AND this THIRD condition is met, then list the page”. That’s why I was using “OR” in the first place, because I wanted any of those values to trigger the page’s appearance.

Not this has me wondering: if using “AND” works when ANY of those values is populated (as I wanted), how can you check if two or more values are populated at the same time, and trigger according to this?!?

Brackets?

This seems to work for me when just quickly toying around. I think I tested most combinations, and I created 2 test files with your YAML frontmatter to test against, giving the fields different/same/no values whilst testing to see what was filtered.

List
From #people/mary
WHERE ((Completed != "Yes") AND ((!Priority OR Priority != "") AND (!Due OR Due >= date(2021-10-11))))
SORT Due, Priority, Status desc

But it’s exactly this what the expression !Completed AND !Due AND !Priority does.
All the conditions need to be accomplished (if all ok, then TRUE). If at least one is FALSE then all the filter is FALSE.

I may be somehow unable to understand the logic behind this, but the way I (still) perceive it, the following…:

WHERE !Due AND !due AND !Priority AND !priority AND !Completed AND !completed

…should translate in English to:

WHERE Due AND due AND Priority AND priority AND Completed AND completed ALL aren't set to some value

And yet, if only ONE of them has a value, the filter works. That’s why I asked in the reply where I mentioned I found the solution that I’m wondering how do you test precisely that, if more than one values are set at the same time, if this filter works with only one of them being set.