Hi.
Task queries work on task-level. Inside task-level you have the sub-level for sub-tasks, and so on…
Your task under a list is a subtasks (the parent list work like a parent-task).
To consider subtasks you need to use this query:
task
where contains(text, "Boby Jean") OR contains(subtasks.text, "Boby Jean")
TABLE WITHOUT ID regexreplace(Tasks.text, "\[.*$", "") AS Task, choice(Tasks.completed, "🟢", "🔴") AS Status, regexreplace(Tasks.subtasks.text, "\[.*$", "") AS Subtasks, choice(Tasks.subtasks.completed, "🟢", "🔴") AS "Subtasks status", Tasks.by AS "By", file.link AS "File"
FROM "Journal" WHERE contains(file.tasks.by, [[Boby Jean]]) FLATTEN file.tasks AS Tasks
I don’t know if I understand well your goal. But I think the issue is in:
generally, if you write WHERE contains(file.tasks.by, [[Boby Jean]]) your are asking this: "only the PAGES where the field “by” - in tasks level - contains “[[Boby Jean]]”;
if you ask for Pages, you get pages, i.e.,(your note contains “[[Boby Jean]]” but also others elements in the array “tasks”;
because this you get also the task with “[[James Paull]]”.
To filter tasks accordingly your goal, you need to apply the filter AFTER the FLATTEN command (because with flatten you get one task per row and not an array. (attention, after the FLATTEN file.tasks AS Tasks you need to use “Tasks” as the new name to “file.tasks”).
Try this:
TABLE WITHOUT ID
regexreplace(Tasks.text, "\[.*$", "") AS Task,
choice(Tasks.completed, "🟢", "🔴") AS Status,
regexreplace(Tasks.subtasks.text, "\[.*$", "") AS Subtasks,
choice(Tasks.subtasks.completed, "🟢", "🔴") AS "Subtasks status",
Tasks.by AS "By", file.link AS "File"
FROM "Journal"
FLATTEN file.tasks AS Tasks
WHERE contains(Tasks.by, [[Boby Jean]])