Search combined dataview fields and display them in one column?

After a lot of trial and error, I’ve got it (mostly) working. The data has to be a task, the search is case sensitive, it won’t search inside an internal note’s real title if using an alias, and sometimes it just doesn’t work even though the code hasn’t been touched. Aside from that, I think I’m ok with what I’ve cobbled together.

I’ve used mnvwvnm’s code from this thread and changed it to suit my needs.

This is the final table:

image

The “Testing Source” in the table is from the note’s yaml. Since tasks also get all the fields from the note they’re located in, I put all the source document’s values in the document note as yaml so every person’s data chunk will inherit them.

Below are the different data formats that will show up on the table correctly. For the last 2 data chunks, those aren’t new lines but the shift+enter lines (or whatever’s the actual term for those).

 - [ ] (person::[[Smith, John]])(person_birthplace::[[Greendale, Colorado]])(person_birthdate::2022-07-21)(person_name::Smith, John O)
 - [ ] (person::[[Smith, John]])
	(person_birthplace::[[Greendale, Colorado]])
	(person_birthdate::2022-07-21)
	(person_name::Smith, John O)
 - [ ] [person::Smith, John]
	[person_name::Smith, John O]
	[person_birthplace::Greendale, Colorado]
	[person_birthdate::2022-07-21]

This is the dataview code:

TABLE WITHOUT ID Tasks.person AS "Person", Tasks.person_name AS "Name", Tasks.person_birthdate AS "BDate", Tasks.person_birthplace AS "BPlace", source AS "Source", file.link AS "File"
FROM "z_Test"
WHERE file.tasks
FLATTEN file.tasks AS Tasks
WHERE contains(Tasks.person_name, "Smith")

Note that this has the limitation that if you’re using an alias for an internal link, it will not see the actual note title. So if you have a link like this: [Greendale, Evergreen County, Colorado|Greendale, Colorado] then contains() will not see “Evergreen” or “County” if you try to search for those terms. It’s also case sensitive, so searching for “green” in the birthplace won’t pick up anything.

This isn’t perfect, I’d like it to work consistently and for the cells to not be wrapped, but it will work while I think about how I can fix it.

If anyone has any tips or suggestions on how to improve this, please let me know.

1 Like