Unexpected dataview query results

What I’m trying to do

I have a folder of blog posts and drafts. I have designated a property called “published”, and those posts that have been published have the value “yes” under “published”, while those that have not yet been published have the value “not yet” under the property “published”.

Things I have tried

I want dataview to give me a list of all notes in a folder that I have not published to my blog. However, as I am still reasonably new to Dataview, I first tried making a list of those which are published, using this code:

list
from "blog posts"
where published = yes

However, much to my surprise, this gave me a list of those notes for which I never gave it the property “published” at all. This is also useful information, as it lets me see which ones I need to add that property to. Can anyone explain why this is the result that it gives, and what I would need to do differently with my code to make the list show only those for which the property “published” contains the word “yes”?

The second unexpected result was when I added an explanation point in front of the equals sign (!=). I thought that should show me everything for which that property is not “yes” (which is my actual goal for this bit of code), but instead I get a list of all of those notes that have any value at all under “published”, no matter if it is “yes”, “not yet”, or even something else entirely. Again, if anyone can explain why this is the result and/or what I need to do differently to get the result I am looking for, I would appreciate it. Thanks!

I don’t know what where published = yes is going to evaluate to. But what is yes? I’m surprised you don’t get some kind of undefined error.

Your published property is presumably a Text property. And so you want "yes" not yes, which specifies that you are pointing to a text string.

Try this instead with quotes:

```dataview
list
from "blog posts"
where published = "yes"
```
1 Like

Seconding rigmarole’s solution. To expound on the reason for the results you saw:

yes has no value.
So WHERE published = yes is asking for notes where published has no value.
And WHERE published != yes is asking for notes where published doesn’t have no value.

You could type anything that’s undefined in there and get the same result: WHERE published != HappyBirthday, or whatever.

But type in something that’s defined, such as true, false or another property name, and get the result you expect: no notes unless published matches the value you entered.

1 Like