Query to generate a table with the todos including columns with the deadline, schedule date and priority

I would like to kindly ask if anyone knows how to create a table using an advance query where each row corresponds to a todo task and has additional columns for Scheduled date, deadline and priority. So, the table view of the query would be like:

Title | Status | Scheduled date | Deadline | Priority

task 1 | todo | 2021-08-08 | | A

Thanks in advance,
Fernando

I have been able to find a solution using this approach:

#+BEGIN_QUERY
{:title “Scheduled”
:query [:find (pull ?b [*])
:where
[?b :block/marker ?marker]
[?b :block/scheduled ?d]
[(!= “DONE” ?marker)]
]
:result-transform (fn [result]
(->> result
(map (fn [r] (assoc r :block/properties {“scheduled” (get r :block/scheduled)})))
)
)
:collapsed? False}
#+END_QUERY

Unfortuntately, the date format is yyyymmdd. It would be nicer to have a better format like yyyy-mm-dd HH:MM. So, if anyone has a solution for that it would be very appreciated .

In the meantime, the current solution is good enough to create arbitrary tables based on Tasks information.

Regards.

2 Likes

It took me a couple of minutes to figure out quotation marks needs to be adjusted…
Allow me to paste a version that can be pasted directly into logseq.

#+BEGIN_QUERY
{
   :title "Scheduled"
   :query [:find (pull ?b [*])
      :where
      [?b :block/marker ?marker]
      [?b :block/scheduled ?d]
      [(!= "DONE" ?marker)]
   ]
   :result-transform (fn [result]
      (->> result
         (map (fn [r] (assoc r :block/properties {"scheduled" (get r :block/scheduled)})))
      )
   )
   :collapsed? False
}
#+END_QUERY
2 Likes

this is brilliant! I’m quite a newbie to the query syntax and want to know how to put deadline at the beginning of a row? thanks!