Dataview Query where the values to match are from a property value list so you don't know what is in it or how many are in it

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

The Current note has a property value called family. It is a property type list. And I put the link backlinks of notes of type “family” into this field. Basically, this is a simple representation of the parents families. There maybe be none, one, or two values based on information known.
Example:
families: [[Smith]] [[Jones]]

Things I have tried

I want to create a table listing all other notes that have at least one matching family in the family property.
I’ve tried
TABLE family, birthday, death
WHERE (file.link.family, this.family)

Doesn’t work. But if I hard code it like this it works perfectly:
TABLE family, birthday, death
WHERE (contains(family, [[Smith]]) OR contains(family, [[Jones]]))

The problem is that I have lots of notes and I cannot hardcode this for each note, I just don’t know the family info until later most of the time, and it would be very time consuming.

My question, I guess is how can I get the information from something like this.family of the current file to work as a replacement for hardcoding each family name?

The trick to these kind of queries is to use any(map( ... )). That is we need to map either list towards the other list, and check if any of the mapped entries are present in the result.

Assuming that your this.family always is noted as list, you should be able to do something like:

WHERE any(map( this.family, (f) => family.contains(f) ))

If this.family occasionally is an actual single value (and not a list property) you’ll need to change it to something like:

WHERE any(map( flat(list(this.family)), (f) => family.contains(f) ))

And in all cases it’s a prerequisite that your links a properly defined similar to the following:

---
family:
- "[[Smith]]"
- "[[Jones]]"
---

If you’ve used something looking more like:

---
family: [[Smith]] [[Jones]]
---

Then your frontmatter is invalid, and you’re fresh out of luck before changing it into valid frontmatter again.