Kanban Plugin and Dataview

I have several Kanban Boards where I have task lists using the Kanban Plugin In,

I want to query these boards (4 of them) to pick all things due TODAY and if there are none then 1-2 future tasks. I want them grouped by project which is identified with a tag, this would show up in each daily note. Also having status or (kanban list) as a sorting option.

Current Kanban board

Query I am trying to get

  1. List tasks due today for all projects
    1. If no tasks due today then list the next 2 future tasks
    2. Projects are identified by a TAG
  2. Group by Project
  3. Show which Kanban List it is in (Not Started, In progress, In review, but do not include completed)
  4. Sort by due date.

Display as table with Task, Due Date, List, Project

I am new to both of these plugins, so help would be appreciated.

1 Like

Update: So I have been able to get what I want more or less, except the fact that my metadata Project will not show in the table

image

Table without id regexreplace(Tasks.text, "\[.*$", "") as Task, Tasks.due As "Due Date", Project as "Project", file.link as "File"
From #project 
Where file.tasks
Flatten file.tasks As Tasks

Any suggests why Projects are not listed even though it is shown in the Kanban and identified as Metadata

I don’t know how kanban works. But if you show the kanban content in md format (to check how metadata is inserted in the task), maybe I can help…

1 Like
  • [ ] Utility Application #project/Alta [due:: [[ 2022-04-28]]] [Project:: [[Alta Apartments]]]
  • [ ] PDF of Drawings #project/Crystal [due:: [[ 2022-04-29]]][Project:: [[Crystal Cove Apartments]]]
  • [ ] PDF of Drawings
    Send to Erik
    Send to Ryan
    @[[2022-04-29]] #project/Alta
  • [ ] Timesheet @[[2022-04-29]]
  • [ ] Access Panels for Attic @[[2022-05-06]] #project/Crystal
  • [ ] Pull Permits for Garages @[[2022-05-06]] #project/Crystal
  • [ ] Updated Foundation Plans for Northern Concrete @[[2022-05-03]] #project/Alta
  • [ ] Mirror Drawings for Building 2 & 4 @[[2022-05-04]] #project/Alta
  • [ ] Invoice for Railings
    Send in with w-9 and COI @[[2022-05-06]] #project/Alta #project/Crystal
  • [ ] Tyvek Email @[[2022-04-29]] #project/Crystal
  • [ ] Scheduling Framing Inspection #project/Crystal [due:: [[ 2022-04-28]]][Project:: [[Crystal Cove Apartments]]]

I have some of them with and some without and I am testing what works

hmm… it’s a very weird format, not very clean.

Dataview “read” the markdown format (what requires a “clean” annotation, under specific rules), not kanban output.

Because that, you need to be careful in the way you enter your information in kanban.

You’re using a query from other post but I’m not sure if you have any experience with dataview syntax…

You know why you’re using regexreplace(Tasks.text, "\[.*$", "")?

You know the structure of metadata and the relation between levels of metadata?

For example, there’s some metadata that if inside a task it belongs to the tasks sub-level, not to the page level. That’s why you use file.tasks.due to get the due date in the inline field due:: inside the task (in the query file.tasks are flatten to Tasks, that’s why you can use Tasks.due).

anyway…
As due::, Project:: is an inline-field inside tasks. Because that you need to target file.tasks.Project. But because the flatten, you need to use Tasks.Project AS Project.

My final point. You need to understand how dataview works to do a better annotation in kanban. If you don’t do a good kanban annotation (or better, a good markdown annotation), then you don’t get good dataview results.

The regexreplace was to just list the task name with nothing else behind it, pulled that from one of your other dataview responses in the forum.

I understand now the layer and things are working better. I am new to both the kanban and dataview

  1. A few other questions since the Kanban defines its lists based on headers in markdown, is there a way to set a Status in the table that shows it as the header? (See Below) This is not a big deal if it is not possible, would just be nice if it could

  2. How would you filter out completed tasks, and also set a duration within 3 days

Not Started

  • [ ] Utility Application [due:: [[ 2022-04-28]]] [Project:: [[Alta Apartments]]]
  • [ ] PDF of Drawings [due:: [[ 2022-04-29]]][Project:: [[Crystal Cove Apartments]]]
  • [ ] PDF of Drawings
    Send to Erik
    Send to Ryan
    [due:: [[ 2022-04-29]]] [Project:: [[Alta Apartments]]]
  • [ ] Timesheet [due:: [[ 2022-04-29]]]
  • [ ] Access Panels for Attic [due:: [[ 2022-05-06]]] [Project:: [[Crystal Cove Apartments]]]
  • [ ] Pull Permits for Garages [due:: [[ 2022-05-06]]] [Project:: [[Crystal Cove Apartments]]]
  • [ ] Updated Foundation Plans for Northern Concrete [due:: [[ 2022-05-03]]] [Project:: [[Alta Apartments]]]
  • [ ] Mirror Drawings for Building 2 & 4 [due:: [[ 2022-05-04]]][Project:: [[Alta Apartments]]]
  • [ ] Invoice for Railings
    Send in with w-9 and COI [due:: [[ 2022-05-06]]][Project:: [[Alta Apartments]], [[Crystal Cove Apartments]]]
  • [ ] Tyvek Email [due:: [[ 2022-04-29]]] [Project:: [[Crystal Cove Apartments]]]
  • [ ] Scheduling Framing Inspection [due:: [[ 2022-04-28]]][Project:: [[Crystal Cove Apartments]]]

In Progress

  • [ ] Mail Kiosk Drawings @[[2022-05-06]] #project/Alta

I’m almost a zero in regex… but yes, it removes everything after the first “[”. This simple fact implies that in this case

[ ] Utility Application #project/Alta [due:: [[ 2022-04-28]]] [Project:: [[Alta Apartments]]]

if you don’t want to see #project/Alta, then you need to send the tag to a place after the first inline field.

About the other questions:

You want to see the status (i.e. the header title) in the table? yes, it’s possible… because you’re targeting tasks and dataview collects the tasks section/headers as metadata.

First, you need to learn how to filter a completed tasks. This means know dataview metadata structure. Do you read the plugin documentation?
I don’t understand what you mean by “set a duration within 3 days”. Means “tasks with due date for the next 3 days”?

You arrive at this point and ask: “yes, but the solution”?
And my answer is: what’s you intention to learn Dataview? Or you want only the solution for your request?

To understand better the metadata structure go to a note with three or four tasks and run this inline query (you need to enable js inline queries in settings > dataview):

`$=dv.span(dv.current())`

There, you’ll see that under the tasks level you have an implicit field called completed, a field you can target in query with file.tasks.completed. This means that if you want to target only not completed tasks, maybe you need to use, after the flatten, something like WHERE !Tasks.completed ("!" means negation).

Explaining the section/header thing is more complicated. You’'l need to use the meta() function > Functions - Dataview

```dataview
TABLE WITHOUT ID
	regexreplace(Tasks.text, "\[.*$", "") as Task,
	Tasks.due As "Due Date",
	Tasks.Project as "Project",
	meta(Tasks.section).subpath as "Status",
	file.link as "File"
FROM #project
WHERE file.tasks
FLATTEN file.tasks As Tasks
WHERE !Tasks.completed
```

I have read through much of the documentation. I always try to learn things first and then ask for help if I cannot figure it out.

What you are writing makes sense completely.

Thank you so much for the help.

I have one more question if you do not mind.

I am trying to dynamically link my Daily Note to my Home page, meaning that today it will show todays note, tomorrow it will show tomorrows note.

Can you help me with the dataview for that too?

If your daily notes title format is “yyyy-mm-dd”, then you can use this:

LIST
WHERE file.day = date (today)

So simple, not sure why i struggled so hard. I tried every variation but that

I ran into another issue with it

Notice how the tasks are grouped by file.name what I want is for all of them to sort by Due Date and have no bearing on file or origin.

Here is my code, I only sort by Due Date

Table without id 
	regexreplace(Tasks.text, "\[.*$", "") as Task, 
	meta(Tasks.section).subpath as "Status",
	Tasks.due As "Due Date", 
	Tasks.Project As "Project",
	file.link as "File"
From "Projects"
Flatten file.tasks As Tasks
Sort Tasks.due asc
Limit 20
Where !Tasks.completed

hmm

First, why this behavior? Because in your case due is a link, not a simple date. And link is a problematic thing to sort. Why? Because link is a path with a multiple behaviors inside obsidian (because the problem of files with same names but in different folders).

  1. In your case you have the multiple due date links (daily notes?) in different folders. That’s why you see some small groups with the wanted sort, because they are in the same folder (and they have a shared path > something like folder/sub-folder/2022-04-28.md)
  2. you can add a column with this target: Tasks.due.file.path (this only works if the file exists! file needs to be real)
  3. once again, I repeat: files need to exist as md files. (and you need to correct all the due links you send because you need to remove the space before the date/name, i.e., this [[2022-04-29]] and not [[ 2022-04-29]]… this is important)
  4. Now, instead of the file.path let’s “extract” the file.name of each link in due with Tasks.due.file.name.
  5. Now, we need to convert this value to a date (to better sort order) using date(Tasks.due.file.name)
  6. Finally, use this to sort your table (important: the order of the commands matter):
```dataview
TABLE WITHOUT ID
	regexreplace(Tasks.text, "\[.*$", "") as Task,
	meta(Tasks.section).subpath as "Status",
	Tasks.due As "Due Date",
	Tasks.Project As "Project",
	file.link as "File"
FROM "Projects"
FLATTEN file.tasks As Tasks
WHERE !Tasks.completed
SORT date(Tasks.due.file.name)
LIMIT 20
```

Yeah, it only worked for files where the daily notes are created, and it sorts the ones where the uncreated notes are at the top of the list.

is there anyway to only include what is between the brackets and sort that?

Thank you for the help and the explanations

Well, the main problem is: if we can’t enter “inside” the file metadata, how to target only the name inside the brackets?

  1. we can try by the “non-existent” path… so, if we use meta(Tasks.due).path what we get? place this in one column and tell me the format of the output. if we get some value also for “false” links, maybe we can use regex to transform the output to the desired date… but it requires some regex knowledge (as said before, I’m almost a nullity in regex) and a solution that works for both: true and false links (due links).

That is it. Thank you I just put meta(Tasks.due).path in the sort and it worked.

Thank you, Thank you, Thank you.

Sorry if I missed in the above replies, but have you found a way to utilize the Kanban stock date format @{date} and still pull in dates from data view?

Since NL dates plugin does not work in a Kanban board, manually typing the [due: date] format is a bit of a hassle.

What I did is you can change what triggers the date function do I did [due:: and then was able to manually select the date, also set mine as a link to my daily note so when it was all said and done I got [due:: [[2022-05-01]]]. That was the most efficient way I could think to do it.

Ah, gotcha, thx. The only quirk I see with that, is Kanban displays the end bracket ] for some reason.

Actually, another approach is to change the Kanban Date format to something like \[\d\u\e\:\:YYYY-MM-DD\]

Then, the default @ date selector can be used, and a custom date display format can be set to hide the due::. Then tasks can be queried with data view normally through “TASK”.

The downside is Kanban still stores the date like @{[due::2022-05-02]}, so the Dataview query pulls in the ugly @{ }. I’m not sure if there is a way to clean that up, otherwise this method would be ideal.

Sorry, not trying to derail your thread - but basic Kanban and Dataview task integration seems more complicated than it should be.