Dataview query using property in the current note

First, search the help docs and this forum. Maybe your question has been answered! The debugging steps can help, too. Still stuck? Delete this line and proceed.

What I’m trying to do

I’ve got a “Person” template (using Templater) that among other things captures what LOB (Line of Business) the person is in.
Example:

contact_type: poc
contact_info: Short description of how I know them
contact_role: Senior Manager, Software Development
contact_lob: Dev Cloud Security & Identity OCI
contact_location: Seattle WA, US
contact_timezone: PDT

I’d like to have a bit of Dataview in the same Person template that will do a Dataview query for other people with the same contact_lob.

Other contacts in Dev Cloud Security & Identity OCI

TABLE contact_type, contact_info, contact_role, contact_timezone, date_last_spoken  
WHERE type = "person"
WHERE contact_lob = "Dev Cloud Security & Identity OCI"
SORT contact_type ASC, file.name ASC

The example above has the WHERE clause hard-coded to that particular Person’s LOB. I’d like to pull the value from the current Person note’s contact_lob property.

Things I have tried

I’ve tried this:

TABLE contact_type, contact_info, contact_role, contact_timezone, date_last_spoken  
WHERE type = "person"
WHERE contact_lob = "`this.contact_lob`"
SORT contact_type ASC, file.name ASC

which returns no data. And if I remove the enclosing double-quotes like this:
WHERE contact_lob = this.contact_lob
I get an error: “Expected one of the following: ‘(’, ‘null’, boolean, date, duration, file link, list (‘[1, 2, 3]’), negated field, number, object (‘{ a: 1, b: 2 }’), string, variable” error.

Hi all, please disregard. I was just making it too complicated by adding double-quotes where it was not needed.

This worked:

## Other contacts in `= this.contact_lob`
```dataview
TABLE contact_type, contact_info, contact_role, contact_timezone, date_last_spoken  
WHERE type = "person"
WHERE contact_lob = this.contact_lob
SORT contact_type ASC, file.name ASC
2 Likes

No disregarding necessary, thanks for coming back with the solution clearly stated for the next person that wants to do this (ie. Me :grin: )

3 Likes

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