Dataview list of notes with no incoming links that contain specific properties

What I’m trying to do

I would like to create a dataview query displaying a list of notes with the following criteria:

  • note has a specific tag
  • note has NO incoming links from other notes that contain specific properties or tags

I’m putting together a gift tracker with dataview. I use a property called “type” to specify if a note is a “person” or a “gift.” Christmas gifts and people I want to give a Christmas gift to both have the tag “xmas.”

If I have an idea for a Christmas gift for someone specific, I will add the “xmas” tag and a property called “recipient” that links to the person’s note. Once I give the gift to the person, I add the date given as the “date” property to the gift note.

I’m trying to create a view of people I want to give a Christmas gift to but have no current Christmas gift ideas for.

Here’s the criteria for this list:

  • type = “person”
  • FROM #xmas
  • NO inlinks with type = “gift” AND tags = “xmas” AND !date

Things I have tried

This lists all people tagged “xmas.” Clearly I have a long way to go :sweat_smile:

LIST
FROM #xmas
WHERE type = "person"

I understand I’ll need to use some combination of inlinks and functions, just not sure how to reference the tags within linked notes for this query.

Thank you in advance for your help!

It’s so nice to read a request which clearly states what you’ve got so far and has a clear concise list of requirements! I like it!!

Here is some untested code, as the test setup would require a little work (and I’m lazy today), but I think it shows what you need to do:

```dataview
LIST 
FROM #xmas
WHERE type = "person"
  AND none( map( file.inlinks, (in) =>
    !in.date AND in.type = "gift" AND contains(in.tags, "xmas")
  ))
```

This utilises a mapping of every file.inlinks to map if that particular inlinks meets your requirements, and then we use a negative constraint that we neither of the mapped list to be true. When mapping each of the inlinks is stored in the in variable, and we can use stuff like in.type to check the type of that file.

With a little bit of luck from a slightly lazy helper, this query should do the trick for you. :smiley:

THIS WORKED!!! Thank you so much for the quick response, I love this app and forum :face_holding_back_tears:

Excited to learn more about this mapping technique, seems like it opens up a lot of possibilities…

Basically map( someList, (m) => ... ) will loop through every item of someList, assign to the variable m, which you then can use in some expression mapping the list to something else in the ....

When used in a context like this, we map to a boolean value to check the status of each item in the list matches some given condition. This can then afterwards be qualified using either of none(), all(), or any() depending on your specifications. See documentation on all & co .

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