```dataviewjs // Define function for expanding search to sub-tasks const taskAny = function taskAny(t, f) { if (f(t)) return true; for (let sub of t.children) if (taskAny(sub, f)) return true; return false; } // Define function for hiding sub-tasks const hideCompletedSubtasks = (t) => ({ ...t, children: t.children.filter(st => taskAny(st, st => !st.checked && st.sf && st.real)).map(hideCompletedSubtasks) }) // Search for tasks const allTasks = dv.pages('(#ToDoDataview or #ProjectDataview) and -"110-SB template"') .where(p => !(p["status-file"] == "Done")) .sort(p => p.file.mtime, 'desc') // no effect at 2022-02-27T12:16 .file .tasks .where(t => taskAny(t, t => !t.checked && t.sf && t.real && !t.text.includes("#GTDWaitingFor"))) .sort(t => [t.due, t.p, t.i]) // Hide completed sub-tasks allTasks.values = allTasks.values.map(hideCompletedSubtasks) // Show tasks as a list const incompleteInAllTasks = allTasks.filter(t => !t.checked).length.toString(); dv.header(5, "==Focus - Project Tasks==: " + incompleteInAllTasks + " tasks") // dv.el("p", allTasks.length) // Task count for (let group of allTasks .groupBy(t => dv.page(t.path).project) .sort(group => group.key, 'desc')) { // dv.header(5, group.key) const incompleteInGroup = group.rows.filter(t => !t.checked).length.toString(); dv.header(5, (group.key + ": " + incompleteInGroup + " tasks")); dv.taskList(group.rows .sort(t => [t.c, t.p, t.i]) , false) } ```