In Dataview: How to show only files containing a certain YAML key?

I have this:

table Documenttype, Status

It gives me a long table of all my notes showing these two YAML keys. Great! However, I only want to show the files I’ve actually given a Documenttype key in the YAML. How do I do that?

Thanks a million for taking the time to answer this newbie question. :slight_smile:

In dataview queries you can add some specifications to delimit the results. In some cases you need to take this in consideration to define the way how you identify certain notes.

The two main ways to do this are by FROM and WHERE.

  • FROM - with “from” you define the source(s), i.e., the pages that initially will be collect by dataview query and where the filters you define are applied. You can select as source folders, tags and incoming/outgoing links. As example, let’s say you have a special tag (#mytag) for documents with «Documenttype» key: then, you can define as source FROM #mytag.

  • WHERE - with “where” you can filter the results after defined the source (you can also use “where” without any “from” > in that case the filter is applied to all your notes in vault… with all risks in performance level, because dataview have more work to do). With “where” you have many options (you need to read the documentation and start trying filters…).
    For your case, let’s take this expression: WHERE Documenttype. If you apply this filter, dataview gives you all the files with the key Documenttype=true, i.e., with some value in “Documenttype” field.
    This means that all pages without “Documenttype” key are excluded and all pages with “Documenttype” empty/null. Only pages with a value in “Documenttype” are considered for your table.
    Let’s say you want to include also pages with “Documenttype” empty. Well, in that case you need to use other filter or define any data to restrict the source/filter.

1 Like

Thanks a million, @mnvwvnm. :slight_smile:

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