Using Dataview with Notion import data

What I’m trying to do

I have a large library of databases converted from Notion to markdown and I want to create some repeatable views of related items. The folder structure is:

.
├── Archive
├── Areas
├── Notes & Ideas
├── Omnivore
├── Resources
├── Resources-Research

Each file in Resources has a large list of related items under Notes & Ideas and Resources-Research. For example Masters Program Research has

---
Type: Resource
Notes & Ideas💡:
  - "[[Latest Research on CogSci programs (@April 5, ]]"
  - "[[My Understanding of what I want to study]]"
  - "[[Looking at Human Factors & Ergonomics research]]"
Related Media:
  - "[[Applied Cognitive Science and Human Factors—MS, Ph]]"
  - "[[Master of HumanComputer Interaction HumanCompute]]"

Where Notes folder is Notes & Ideas and Related Media’s folder is Resources-Research. Each of these related notes and media has the following:

---
Resources:
  - "[[Masters Programs]]"
---

I’m trying to query with:

LIST 
FROM "Resources-Research" OR "Notes & Ideas"
WHERE contains(Resources, "[[Masters Programs]]")

But I get no results. How do I properly query the list of links here?

Bonus: Ideally, I could set up a query I could reuse for each Resource, like contains(resources, file.name).

Things I have tried

I’ve also tried any(Resources, "masters"), Resources = "[[Masters Programs]]" and every iteration I can imagine in there but get either no results or every result from the folders.

I’ve spent a few days going through the documentation but seem like I’m missing something fundamental here and I’d appreciate the pointer.

It’s unbelievable, but I found a conversation that covers exactly this as soon as I wrote this out. For reasons I don’t understand yet, removing the quotes around the link get me what I need:

WHERE contains(Resources, [[Masters Programs]])

The vital difference between those two are that [[notename]] is an actual link to the “notename”, but "[[notename]]" within a dataview query is just a string which happens to contain nothing but a link. So this is kind of confusing when combined with frontmatter texts:

aDoubleArray: [[ aDoubleArray ]]
aLink: "[[aLink]]"
aText: '"[[aText]]"'
---

```dataview
LIST aText 
WHERE aLink = [[aLink]]
  AND contains(aText, "[[aText]]")
```

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

Which displays as:
image

This would list the note the text was contained in, and you can see how the first variant is just considered a strange property (see the question mark in front, and the yellow color), and in the display you’ll see the two bullet points indicating the double list. The link is shown as a link, and it compares as a link.

The text is shown as a text (but required extra quoting with single quotes, although within the query we can use contains() to check for the string value…

Sorry if this confuses you even more, but the gist of it is that to compare links in a dataview query you need both to be links, which can be achieved using the [[note name]] syntax (or even link("note name") syntax).

1 Like

That definitely makes sense when you break it down, case by case. Thank you @holroy!

1 Like

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