How can I query tasks completed today, but exclude tasks from today's daily note?

Hello! Here’s what I’m expecting:

  • dataview query to get incomplete tasks scheduled for today, or due in the current week
  • completed tasks defined in notes other than my current daily note

My current query looks like this. The date string is provided by templater according to today’s date.

```dataview
TASK
WHERE path != this.file.path
	AND (typeof(scheduled) = "date" AND scheduled = date(2023-11-29)) 
	OR (typeof(due) = "date" AND due >= date(2023-11-27) AND due <= date(2023-12-03))
	OR (typeof(completion) = "date"  AND completion = date(2023-11-29))
GROUP BY header

My problem is that this query somehow still shows the tasks in the current note (I use this query in my daily note).

I list my daily task under ## Task, I had suspicions that the task’s path would include the nearest heading, but I had no way of confirming this. I would really appreciate any help I could get. Thank you in advance~!

Your where clause somewhat simplified is: not this file AND scheduled today OR due this week OR completed today. This is an ambiguous statement related to what happens if some of these are false. It turns out that dataview interprets this as: (not this file AND scheduled today) OR due this week OR completed today.

I believe that you intended it to be: not this file AND (scheduled today OR due this week OR completed today). If this is the case you need to add parentheses around the three last expressions like in:

```dataview
TASK
WHERE path != this.file.path AND 
 (   (typeof(scheduled) = "date" AND scheduled = date(2023-11-29)) 
  OR (typeof(due) = "date" AND due >= date(2023-11-27) AND due <= date(2023-12-03))
  OR (typeof(completion) = "date"  AND completion = date(2023-11-29))
 )
GROUP BY header
```

Does that solve your issue? If not, we need to see some example tasks with notes on which you want included and not included for the list from 2023-11-29.

The parentheses worked :"))
It completely slipped my mind that AND takes precedence OR. Thank you so much!

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