Show only valid occurrence from daily notes in dataview

Hi all,

I currently have a field called ‘Occurrence’ in which I describe what occurrences have taken place during the day.

For example:
Occurrence:: Met [[John]] today, talked about going to the movies.
Occurrence:: Had dinner with [[mother]] in [[lovely restaurant]].

I’ve got my people-card, where I want to fill a list with occurrences with that person. I use:

TABLE Occurrence
FROM “Reviews/00 Days”
WHERE contains(Occurrence, “John”)

But when I use that dataview-query, I get both results in stead of just the one where John is mentioned.

Any tips on making the filter work better?

In these cases Occurrence are a list/array of values

  - value 1
  - value 2

and you’re asking for pages where it contains “John”.
Then the results are the pages where it exists and, without any special filter to each value in Occurence you’ll see all the values in that page.

To do the wanted filter you need to “destroy” the array (using the command FLATTEN, and only then filter by each Occurrence.

Try this

TABLE Occ AS Occurrence
FROM “Reviews/00 Days”
FLATTEN Occurrence AS Occ
WHERE contains(Occ, "John")
1 Like

Aha, that’s it! Thanks for the explanation as well, this will help me in future cases!

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