I am trying to create a TABLE using dataview. The table would have two main columns, one is the file name, the other is the minimum date of incomplete tasks.
TABLE
string(file.frontmatter.project) AS "Course",
dateformat(minby(file.tasks.due, (t) => t), "dd-MMM-yyyy") AS "Due",
FROM #tasks
I have been struggling how to add the filter function to fit in the minby function. Thanks in advance for your help!
Canāt you simply do dateformat( min(file.tasks.due), "dd-MMM-yyyy") as Due ?
Maybe the following query also could be helpful in you want to filter out just incomplete tasks which have a due date:
```dataview
TABLE rows.task.text, rows.task.due, min(rows.task.due), dateformat( min(rows.task.due), "dd-MM-yyyy")
FLATTEN file.tasks as task
WHERE task.due and !task.completed
GROUP BY task.path
```
More customisation related to how to visualise the output could surely be done, but I just kept it at a minimum here to show the concept.
Thanks for the advice. However I got the same results⦠instead of having the minimum date from incomplete tasks, I got the min results from All tasks
Thanks so much for the advice and I will definitely try!
You could possibly extend the WHERE clause, and simplify the min() functions somewhat. So lets refine it yet a little bit:
```dataview
TABLE
string(file.frontmatter.project) AS "Course",
dateformat( min(dueDates), "dd-MM-yyyy" )
FLATTEN array(map( filter( file.tasks, (t) => !t.completed AND t.due),
(t) => t.due )) as dueDates
WHERE length(dueDates)
```
This uses FLATTEN to produce a list dueDates consisting of tasks which have a due date and are not completed. The final table will only show rows where this list has any elements, and then weāll find the minimum of those dates, and display it in your wanted format. For good measures, Iāve also added your āCourseā columnā¦
Try that just nowā¦if i put the FLATTEN before FROM, it returns āunrecongized query operation ātagāā
I was trying to create a table with all the courses with the earliest due date.
However, each course has it own files so I donāt have to pull dates from multiple files. All I need is to get the min(date) for a single file.
Oopsie⦠My bad, I tested on very full set of tasks, so I didnāt check the status of these tasks, so !t.complete would return a positive value (but not the uncompleted tasks).
Iām going to update the queries for the posterity, sorry for the confusion.