My Dataview Use Cases in #Obsidian
One of the most downloaded community plugins in the Obsidian universe is Dataview. It allows you to treat you vault as a searchable, queryable database. Using the file properties and inline fields you can use Dataview Query Language (DQL) to ask questions of your vault. I use Things 3 for task management, so I don’t use Dataview to manage my todo list as many people do, but I do use it in for a number of other purposes.
Help Building Queries
There is a free tool you can use to help with the learning curve with Dataview. “The Basic Dataview Query Builder will guide you through some questions and put together a Dataview query based on your answers. You can use this query as-is in your vault or as a starting point to refine a more advanced query.
The goal is to help you on your first Dataview queries and to give you a better understanding of the syntax and needed information to build Dataview queries from scratch.”
Daily Note Template
I have two Dataview queries in my Daily Note template. I have them formatted as callouts so that I can fold them up when I don’t need to see the information and therefore don’t have to do a lot of scrolling around.
The first callout shows me the notes created on the same date the daily note was created.
[!abstract]Today's New Notes ```dataview LIST WHERE creation-date = this.creation-date ```
The second callout shows me the notes modified on the date the daily note was created.
[!abstract]Today's Modified Notes ```dataview LIST WHERE modification-date = this.modification-date ```
They appear like this in the note.
Maps of Content Based on Tags
I have a folder of notes in my vault I call Meta. These are notes about other notes. Several of these contain a map of content (MOC) for my areas of interest. One of these contains my notes an a Mac automation program I use and that I study to improve my scripting skills, Keyboard Maestro. The Dataview query for a tag-based note looks like this:
```dataview
LIST
FROM #KeyboardMaestro
SORT file.name ASC
```
Speaking of Tags
I use tags extensively in my vault. One of my meta notes is a clickable list of all the tags I have. It’s like the tags pane in the Obsidian interface except it’s in note form. I can edit it easily enough so that It only shows me the notes from a certain folder if I want. The Dataview query for that notes looks like this.
```dataview
LIST length(rows)
WHERE tags
FLATTEN file.tags as tags
GROUP BY tags
SORT key asc
```
The result is a list with the number of notes with that tag and a clickable link that will open a list of notes in the left pane.
A Table with URLs
Dataview lets you create tables with multiple columns as well as lists. I user URL as a field in my properties for several categories of notes. Since I’m relatively new to Obsidian, I have a lot of notes on different workflows and plugins. Once again, I have a meta note that contains not only links to my notes, but also links to the web pages where the information came from. The query is formulated like this :
```dataview
TABLE url
FROM Obsidian
SORT file.name ASC
```
The result is:
A Little More Complex
I work at a small private university. My role there causes me to interact with everyone on staff as well as the faculty and administration. I have a note for each person with details of out meetings and interactions. I also have notes in my vault for plenty of other people to include writers, vendors, my family and more. I need a MOC just for work though and the following query returns the information for people (criteria 1) who work at my university (criteria 2) and their role (criteria 3).
```dataview
LIST role
FROM #people
WHERE org = "MU"
SORT file.name ASC
```
The result is
Special Cases
Not all my meta notes contain links to other notes. I have an collection of over 500 quotes in my vault. Some of them are from an app on my phone. others have been imported from other people’s vaults and some have been added one at the time since i started using Obsidian. One of the fields in the metadata is Topics: which I use instead of tags so as not to clutter up my tags database. Because I have notes from so many different sources, the topics field was a mess with different capitalization rules, punctuation etc. I needed a way to list all of the topics so that I could use a text editor to do a search and replace across my vault to standardize things. The user holroy on the Obsidian.md forum wrote the following query for me.
```dataview
LIST length(rows)
FROM "Quotes"
WHERE topics
FLATTEN topics as topic
GROUP BY topic
SORT key asc
```
The results: