After searching through the forum here I still can't find the answer so had to make a new post. Sorry if this is previously asked

After searching through the forum here I still can’t find the answer so had to make a new post. Sorry if this is previously asked.

I want to make a table of all the meeting notes where the yaml array “attendees” includes, lets say “Person A”.

With regular dataview I am able to to this with:

```dataview
TABLE
WHERE contains(attendees, "Person A")

However, I would like to filter notes in the same way (“array contains”) with a dataviewjs in a templater template but can’t figure out how. Since it is an array the regular .where(p => p.attendees ===“Person A”) does not work.

Could anyone give me a tip on how I could add the filter yaml array “attendees” includes “Person A” to the dataviewjs query below:

```dataviewjs
dv.table(["Project", "Meeting title", "Date", "Link"],
dv.pages().where(p => p.noteType === "meeting")
    .sort(p => p.date)
    .map(p => [p.project, p.title, p.date, p.file.link]))

Values in attendees are strings? A list of strings?

In your example, you want to add a new filter or replace the p.noteType === "meeting"?

“attendees” are a list of strings. The frontmatter of a meeting note could look something like this:

---
title: meeting title
date: 2022-12-06
noteType: meeting
project: project A
attendees:
 - person A
 - person B
 - person C
---

I would like to add the new filter so that only notes included in the table are those where key noteType=meeting and where “attendees” contain “person A”.

Hope that was clear.

ok. try this

dv.table(["Project", "Meeting title", "Date", "Link"],
dv.pages().where(p => p.noteType === "meeting" && p.attendees?.includes("person A"))
    .sort(p => p.date)
    .map(p => [p.project, p.title, p.date, p.file.link]))
2 Likes

Thank you so much! A simple questionmark solved it!

The question mark is needed to avoid errors if/when the attendees field is missing. With the question mark the code gracefully exits that statement, whilst without it it would cause dereferencing a null value (which is no good).

1 Like

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