Comments (25)
I have good news and bad news. The good news is this is now possible; the bad news is you need to write a tiny bit of javascript for it:
```dataviewjs
dv.taskList(dv.pages("#projects").file.tasks.where(t => !t.completed));
```
from obsidian-dataview.
This has been on my TODO list forever since it's conceptually simple, my task query implementation is just a hack. Will improve.
from obsidian-dataview.
cool, how can I search in every note in my vault?
With "". dv.pages works like sources in dataview. You need to quote it though - so '""'
(single-tick, quote, quote, single-tick)
dv.taskList(dv.pages('""').file.tasks.where(t => !t.completed));
from obsidian-dataview.
This would be awesome. Is there a workaround in the meantime?
from obsidian-dataview.
This would be a great addition! Hope to see it implemented soon.
from obsidian-dataview.
cool, how can I search in every note in my vault?
from obsidian-dataview.
I have good news and bad news. The good news is this is now possible; the bad news is you need to write a tiny bit of javascript for it:
```dataviewjs dv.taskList(dv.pages("#projects").file.tasks.where(t => !t.completed));
Thank you!
Is it possible to list it in modified order?
from obsidian-dataview.
Is it possible to sort the tasks based on file name?
from obsidian-dataview.
You mean for tasks that are appearing in a file? Like give me all from "Project X"?
```dataviewjs
const targetPage = "Project X"
dv.taskList(
dv.array(
dv.page(targetPage).file.tasks
).where(t => !t.completed)
)
```
You just need to 'cast' it as a dataview array.
from obsidian-dataview.
Thanks for the prompt reply! @danielhauck Sorry for not being clear about what I am trying to achieve. Now I will elaborate it as follows.
First, I may query all tasks from files within a folder with something like:
dv.taskList(dv.pages('"Daily note"')
.file.tasks
.where(t => !t.completed)
)
This lists all uncompleted tasks from files within the folder Daily note
. However, I am not sure how are the task files sorted. Therefore, I would like the tasks to be sorted based on the file name where they come from, e.g. Note A
, Note B
, Note C
, etc. Each of such a note/file consists of a series of uncompleted tasks.
I tried the following options (without knowing if the syntax is correct or not :-(, however), but neither of them worked for me.
dv.taskList(dv.pages('"120-Daily note"')
.file.tasks
.where(t => !t.completed)
.sort(p => p.file.name, 'asc')
)
dv.taskList(dv.pages('"120-Daily note"')
.file.tasks
.where(t => !t.completed)
.sort(t => t.file.name, 'asc')
)
Of course, it would be great if the tasks from individual files/notes can also be somehow sorted, e.g., based on task description.
I also tried your code, and it gives the following error message:
const targetPage = "Daily note"
dv.taskList(
dv.array(
dv.page(targetPage).file.tasks
).where(t => !t.completed)
)
Evaluation Error: TypeError: Cannot read property 'file' of undefined
at eval (eval at <anonymous> (eval at <anonymous> (app://obsidian.md/app.js:1:1212458)), <anonymous>:5:28)
at DataviewInlineApi.eval (eval at <anonymous> (app://obsidian.md/app.js:1:1212458), <anonymous>:12129:33)
at evalInContext (eval at <anonymous> (app://obsidian.md/app.js:1:1212458), <anonymous>:12129:49)
at DataviewJSRenderer.eval (eval at <anonymous> (app://obsidian.md/app.js:1:1212458), <anonymous>:12591:17)
at Generator.next (<anonymous>)
at eval (eval at <anonymous> (app://obsidian.md/app.js:1:1212458), <anonymous>:26:71)
at new Promise (<anonymous>)
at __awaiter (eval at <anonymous> (app://obsidian.md/app.js:1:1212458), <anonymous>:22:12)
at DataviewJSRenderer.render (eval at <anonymous> (app://obsidian.md/app.js:1:1212458), <anonymous>:12583:16)
at DataviewJSRenderer.eval (eval at <anonymous> (app://obsidian.md/app.js:1:1212458), <anonymous>:12578:28)
from obsidian-dataview.
Ah, this is a short-coming of the dv.taskList()
implementation; I need to add some configuration to be able to decide how you sort tasks and files. @wenlzhang Would you mind filing an issue with the contents of your comment for tracking?
from obsidian-dataview.
That's great news! Looking forward to that! @blacksmithgu This feature request can be found in the following issue:
#407
from obsidian-dataview.
Is there a way that instead of telling it to look at a file with dv.pages I can have it look at all the files in a folder?
from obsidian-dataview.
You still use dv.pages, just providing the path to the folder: dv.pages('"path/to/folder/"')
.
from obsidian-dataview.
Ah, I was just using dv.pages("x/y/z") instead of dv.pages('"x/y/z"').
from obsidian-dataview.
Yay, tasks can now be filtered on completed!
TASK WHERE !completed
You can also do a fair bit other stuff with them, like using the text
property (which contains their text), or subtasks
(which contains a list of subtasks), and so on!
from obsidian-dataview.
Thanks for @sheeley for implementing this functionality.
from obsidian-dataview.
Does this functionality extend to DataView Table queries? I'm trying to count all completed tasks onto a table as a proof of concept. I later want to count completed completed tasks per folder. For some reason I can't get any tasks to query.
Here's my query
TABLE length(rows) as "Count Completed Tasks"
FROM "Test"
WHERE completed
Flatten file.tasks
GROUP BY file.folder
Running it barebones and just trying to query completed tasks without fancy groupings doesn't yield any results either. Running the query as a Task rather than a Table works, however.
This is how my notes are set up, in their own folders as follows.
from obsidian-dataview.
The task list and table depend upon different implementations internally. I could see this being interesting.
@blacksmithgu think there should be a task table?
from obsidian-dataview.
@blongty @sheeley The correct move here is to (1) allow FROM statements to select tasks instead of files, and (2) implement task renderering support so that they work automatically in both list views and table views.
This is something @sheeley can look into in the short-medium term if he has time / interest.
from obsidian-dataview.
@blacksmithgu happy to. Thoughts on the syntax?
task table foo, bar from ...
table foo, bar as task from
table foo, bar from tasks
And for the functionality, would you expect a single task per row? Or would it be possible to render a task per cell? I could see value in the latter.
from obsidian-dataview.
For the syntax, I'm thinking TABLE foo, bar FROM TASKS <source query>
; this particular syntax is mainly because we can extend it easily to support sections and other metadata (FROM SECTIONS ...
).
I think the default would be one task per row, allowing "task lists" via a GROUP BY
.
from obsidian-dataview.
Does this functionality extend to DataView Table queries? I'm trying to count all completed tasks onto a table as a proof of concept. I later want to count completed completed tasks per folder. For some reason I can't get any tasks to query.
Here's my query
TABLE length(rows) as "Count Completed Tasks" FROM "Test" WHERE completed Flatten file.tasks GROUP BY file.folder
Running it barebones and just trying to query completed tasks without fancy groupings doesn't yield any results either. Running the query as a Task rather than a Table works, however.
This is how my notes are set up, in their own folders as follows.
Did you find a way to count the tasks? I am trying to do the same thing in a standard dataview query where I want to report the number of open tasks and potentially exclude results returned from pages that have no tasks.
from obsidian-dataview.
this also worked for me:
TASK
WHERE task != completed
from obsidian-dataview.
task where !completed works as well
from obsidian-dataview.
Related Issues (20)
- Bug report - inlinefield rendered inside a inline code and it make a mess HOT 1
- Dataview causes screen flickering. HOT 1
- Vulnerability HOT 4
- Implement `title` field for first H1/H2 heading (if no title field exists) HOT 1
- codeblock with "=" causes a PARSING FAILED HOT 2
- Table query suddenly shows only the number of results but not the results anymore HOT 3
- Vscode extension for data view plugin HOT 4
- Inline queries aren't rendered anymore (Desktop only) HOT 1
- Bug report DataView can not render emoji character and show as null HOT 5
- Bug report HOT 14
- Bug report HOT 2
- Embedded notes miss link to note HOT 1
- glob pattern matching HOT 4
- Bug report- the task from in the dataview can not display and cause the obsidian helper(Renderer) CPU used 100% HOT 3
- Dataview do not update results HOT 1
- Bug report dv.lists Evaluation Error: TypeError: e is not a function HOT 2
- Calculated table columns repeats the value
- Dataview breaks links in preview mode when linking to aliases that include ::
- Cannot use Regex Special Characters HOT 2
- Getting the same page metadata even after some specific page metadata have changed
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from obsidian-dataview.