Cannot query nested links

Dear all, I have a simple doubt, I must be doing something incorrectly. Here’s the case.

I’m using Obsidian as a task/project management tool andI have my YAML frontmatter like this for all my taks:

---
title:  Example task
uid: 1675165688
CreatedTime: Tuesday 31st January 2023 08:48
BlockedByTask: 
HideUntil: 2023-02-07T06:00
Due: 2023-02-01
Impact: 2
Urgency: 1
Status: waiting
Next: true
Done: false
DateDone: 
RequestedBy: 
Stakeholder: 
 - "[[Person 1]]"
 - "[[Person 2]]"
 - "[[Person 3]]"
WaitingWhom: "[[Person 2]]"
LaptopAffected: 
MobileDeviceAffected: 
tags: task
---

Then, my query code is below:

TABLE
	Status,
	RequestedBy,
	Stakeholder,
	WaitingWhom,
	Impact + Urgency AS "Priority"
FROM
	#task 
WHERE
	Done = false AND
	WaitingWhom = [[Person 2]]
SORT
	(Impact + Urgency)

That works fine, no issues there as the Persons are links and they are “queriable” in this case.

However, in my framework, sometimes a task is not depending just in one person, but a couple of them or more. So, if I try this, for example (I’ll put only the part that matters), the query somehow will not work:

WaitingWhom: 
 - "[[Person 2]]"
 - "[[Person 3]]"

Things I have tried

I’ve tried this syntax as well, but it is not working:

WaitingWhom: ["[[Person 2]]","[[Person 3]]"]

Even if I let it just one person, but in this format below, it does not work:

WaitingWhom: 
 - "[[Person 2]]"

What I’m trying to do

Simply put, I need a way to be able to query a column (frontmatter attribute) in a way that it’ll contain 2 or more items. Is this possible?

---
whom:
- [[Person 1]]
- [[Person 2]]
- [[Person 3]]
why: [[[Person 1]], [[Person 2]], [[Person 3]]]
where:
- "Hi"
- "Hello"
- "Good morning"
what: ["Bye", "Cya", "Good night"]
whence: "[[Person 1]], [[Person 2]], [[Person 3]]"
---

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

All of those are legal, and the two first, whom and why, will list the links as an array, readily available for testing. The next two, where and what, will list texts (or strings) as array. And the final one, whence, will list all three links as one text.

Hope that clarifies how to declare them, and make them ready for a query.

Thanks for your quickly reply, @holroy , but this stills not solve my issue.
I’ve tried taking out the quotes (“”) as in your whom and why examples and, the moment I do it, it is not queriable anymore.
Also tried whence and it does not work; it is only queriable if I leave it in this format:

WaitingWhom: "[[Person 2]]"

I’m using dataview only because I do not know how to use the JS counterpart.

I jumped the gun a little bit in my previous post, and I’m sorry for that. I confused you with the syntax of inline fields, which will be incorrect when used in the frontmatter. (And further tests of mine, showed these as array of arrays… Very confusing… )

So to correctly list multiple links in the frontmatter, do use your original format:

WaitingWhom:
- "[[Person 1]]"
- "[[Person 2]]"
- "[[Person 3]]"
WhomWaiting: [ "[[Person 1]]", "[[Person 2]]", "[[Person 3]]" ]

The query you originally used is only usable for one person, which you’ve discovered, that is WaitingWhom = [[Person 1]].

A query which works for both single and multiple values in this case, would be contains(WaithingWhom, [[Person 1]]).

Do note that this will still list all the WaitingWhom guys listed in your field, and not just the matching guy.

If you only want to show the matching guy, you could do something like the following:

```dataview
TABLE
	Status,
	RequestedBy,
	Stakeholder,
	theGuy as WaitingWhom,
	Impact + Urgency AS "Priority"
FROM
	#task 
FLATTEN filter(WaitingWhom, (p) => p = [[Person 1]]) as theGuy
WHERE
	Done = false AND theGuy
SORT
	(Impact + Urgency)
```

@holroy , thanks a lot!
Now I realized that the frontmatter is correct, but the query was not; using the following solved my issue:

contains(WaitingWhom, [[Person 1]])

I’m guessing that by using the way I was doing it (see below) was stating that the result should be equal to that person only, so no other “Persons” included; contains work for me, solved. Below, the one I was using that was not returning the results:

WaitingWhom = [[Person 1]]

It is true that it’ll return the other people as well (in case the task depends on more people in this case), but that was what I was wanting all along, so it is a perfect solution. Thanks again! :slight_smile:

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