Dataview table of tasks without metadata

What I’m trying to do

Create a table with

  • the title of the tasks
  • due date
  • prioty
  • assigned to who (inline field of task)
  • and source file where the tasks are found

Things I have tried

``` dataview
TABLE WITHOUT ID
	Tasks.text AS "Task",
	Tasks.due AS "Due Date",
	Tasks.priority AS "priority",
	Tasks.assigned AS "assigned to",
	file.link AS "source file"
from #active AND #researchproject
WHERE file.tasks 
FLATTEN file.tasks AS Tasks
sort priority desc

Rather stuck… Any help highly appreciated.

1 Like

You’re not stating what works, or doesn’t work in your current solution. Nor what you what like the output to look like if you got it like you want it.

True, I tried to get the title of the tasks without all the metadata attached to it. Hence if a tasks is noted as

- [ ] this is a task [assigned:: [[John]]] 

I would like the table to only show the title aka ‘thios is a task’. This worked using

dataview
TABLE WITHOUT ID 
	regexreplace(Tasks.text, "\[.*$","") as "Tasks",
	Tasks.due AS "Due Date",
	Tasks.priority AS "priority",
	Tasks.assigned AS "assigned to",
	file.link AS "found in:"
from #active AND #researchproject
WHERE file.tasks 

FLATTEN file.tasks AS Tasks
sort priority asc

This works as long as regex can do its job aka search for “[.*$”,". Now I only need to get rid of those tasks where first the icon ‘due date’ is used.

In the segment below a note with some queries solving your issue is presented in full.

Full test file with queries

Try out the following stuff in a note of its own:

- [ ] Humpty, dumpty 📅 2023-11-11  🛫 2023-11-12 made a [field1:: value1] great fall [field2:: value2]
- [ ] Humpty, dumpty ⏳ 2023-10-14 made a [field1:: value1] great fall [field2:: value2] 

```dataview
TABLE WITHOUT ID
  task.text as "Task",
  task.due as "Due date",
  task.start as "Start",
  task.scheduled as "Scheduled", 
  task.priority as "Priority",
  task.assigned as "Assigned to",
  file.link as "Source file"
WHERE file = this.file
FLATTEN file.tasks as task
```

## Replace galore

### A greedy field regex
```dataview
TABLE WITHOUT ID
  text
WHERE file = this.file
FLATTEN file.tasks as task
FLATTEN regexreplace(task.text, 
  "\[.*$", "") as text
```

### A not so greedy field regex, and a select date replacement

```dataview
TABLE WITHOUT ID
  text
WHERE file = this.file
FLATTEN file.tasks as task
FLATTEN regexreplace(regexreplace( task.text, 
  "\[[^\]]+\]\s*", "§"),
  "[📅🛫]+ \d{4}-\d{2}-\d{2}\s*", "£") as text
```

My test tasks are as follows:

- [ ] Humpty, dumpty 📅 2023-11-11  🛫 2023-11-12 made a [field1:: value1] great fall [field2:: value2]
- [ ] Humpty, dumpty ⏳ 2023-10-14 made a [field1:: value1] great fall [field2:: value2] 

Those queries addresses three issues with your current solution:

  • "\[.*$" – This replace everything from the first [ till end of line. In my test cases this also removes the text “great fall”. Not ideal
  • "\[[^\]]+\]\s*" – Yes, this is ugly… But it does check for the shortest possible variant of [ ... ] with optional space after it. This ensures a field removal in most cases (except where you include links within the field… ). In my test case I replace this with § just so one could see where it replaces stuff
  • "[📅🛫]+ \d{4}-\d{2}-\d{2}\s*" – This replace either the due or start date (and can easily be extended to other date icons) followed by a date, with a £ (in my test case)

The result of the last two queries showing the fault in the first issue, and the fixes of the second query:

Notice how the scheduled date hasn’t been removed (yet), due to it missing in the character class in the date regex.
You could/should of course replace with "" after you’re done testing the queries. :smiley:

Thanks for the reply, and solution indeed.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.