Dataview query with metadata in the FROM clause

I’m trying to create a generic dataview query that I can include in a page template that I regularly use. So, I’d like to it rely on some metadata that is common to these page types, so then I don’t have to touch anything apart from populate some page metadata. The metadata in question is an up:: [[some page]] link.

The dataview query I’d then like to have is the following, which would give me any unresolved tasks that link to the page referenced by up:::

WHERE !completed AND !=

But no matter how I try to write the FROM clause, I can’t seem to get it to look at the page that up:: refers to, it just doesn’t seem to consider it.

Reading the documentation on Expressions seems to suggest this should be possible. Can anyone help me see what I’m missing here?

Forego the FROM clause, and rather add something like = this.up into the WHERE clause, or contains(file.outlinks, this.up). In addition (update: if it’s a link field in the frontmatter) you need to add quotes around the field, to make dataview recognise it as a link, and not a double array.

1 Like

Thank you for the kind reply, much appreciated. I came here to update that I’d just stumbled onto the same conclusion as your latter suggestion, and this seems to do the trick. I suspect I was missing the this. prefix earlier, and that’s why it wasn’t working when I previously tried that route :see_no_evil:

In addition you need to add quotes around the field, to make dataview recognise it as a link, and not a double array.

I couldn’t quite follow this part, are you referring to the metadata itself, or trying to reference it in the dataview? For reference for anyone else, the following dataview query achieves what I was after:

WHERE !completed AND != AND contains(file.outlinks, this.up)

When it’s an inline field, you’re set, but if it had been a frontmatter field, you’d need to use up: "[[some page]]". This is a typical error when defining fields, so I mentioned it just to cover the bases.

Gotcha, thanks for clarifying that. I hadn’t appreciated the differences between those, and since I’m using inline fields just about everywhere, I hadn’t run into this. Thanks again for your help!

1 Like