Ric Raftis Consulting logo with image of Ric Raftis

Ric Raftis Consulting

Automating Obsidian Daily Notes Part 4 – Using Dataview Queries

Ric Raftis Consulting logo

Introduction

This article continues the series on automating Daily Notes in Obsidian. This time we explore including Dataview queries in the Daily Note template so certain information appears every time we create a Daily Note. The examples to be used here will be to create three queries. The first is a reminder for articles I intend to write. The second shows me all notes I have created on the date of the Daily Note and the third shows all notes I have worked on or modified on that day.

Bear in mind that these are just examples that suit my particular needs and you can use dataview to include all sorts of different queries. References to help and assistance will be included at the foot of this article.

Callouts in Obsidian

I always put my Dataview queries in Callouts. This is just a personal preference because I can hide the query results or have them display by default. The callouts also display in a manner that creates contrast in my notes. You can find out more about callouts in another article I have written on compacting Obsidian notes.

Obsidian has quite a number of callouts you can use. You might like to explore the Community Plugin “Callout Manager” for ideas. For the purposes of this article however, we will confine ourselves to a simple callout.

1. Articles to Write

This dataview query is based on a tag in any note I start where I intend to write an article. If you have followed other examples of videos and articles you will be familiar with putting the following frontmatter at the top of your note via a template so it appears in every new note. Refer to this article for more information.

up:: Link to next note up the hierarchical chain
tags:: # todo/write (remove space between hash and first letter)

For every article I intend to write, I create a note as a placeholder and structure it with that tag. Once the article is written, the # todo/write tag is removed in the publishing process.

So back to the Daily Note. In the area where you wish to have these articles insert the following code assuming you are using the same tag mentioned above.

>[!EXAMPLE] Articles To Write
>LIST
>FROM #todo/write 
>SORT file.name asc
Image of callout

If you don’t want the callout to be displayed in full view, then add a minus sign after the closing bracket of EXAMPLE. Once you exit the code area, the callout should display as follows.

Option

Another method of doing something like this is to create a specific note called “Articles to Write” or whatever it is you wish to keep track of. Put the dataview query in that note and then create a Bookmark using Obsidian’s new core plugin to take you to that specific note. Nick Milo has just made an excellent video on this new feature.

2. Notes Created Today

This callout will automatically record all new notes you have created today. I keep this at the bottom of my Daily Note. The code for this is very simple:

>[!EXAMPLE]+ New Today
>LIST
>WHERE file.cday = this.file.day
>SORT file.name asc

This query is simply searching for all files where the creation date (file.cday) is equal to today (this.file.day) and then sorts the files in ascending order. Done correctly, it should display similar to the below example.

Image of callout

3. Note Modified Today

A similar query to the one above but tells you all the files you have worked on today. This will include any you have created because you have worked on them too. The code to generate this callout is:

>[!EXAMPLE]+ Modified Today
>LIST
>WHERE file.mday = this.file.day
>WHERE !contains(file.path, "91.23 - 2023")
>SORT file.name asc

This query is looking for files modified (file.mday) that equal today (this.file.day) and are not located (!contains) in the folder where I keep all my Daily Notes (file.path, 91.23 – 2023) and then sorts the files in ascending order.

Image of callout

Conclusion

These are just a couple of examples of what can be done in your Daily Notes, or other notes for that matter, with Dataview queries. It is a very powerful plugin and we have only just scratched the surface. Some people write some truly amazing queries using the plugin. So good luck with these beginner queries and I hope it adds some interesting viewing to your Daily Note that is automated.

Bonus Video

[embedyt] https://www.youtube.com/watch?v=U-acSbdvP-8[/embedyt]

References

Basic Dataview Query Builder
Obsidian Callout Plugin (but available by browsing Community Plugins in Obsidian)
Nick Milo’s excellent video on Bookmarks

Facebook
Twitter
LinkedIn

6 thoughts on “Automating Obsidian Daily Notes Part 4 – Using Dataview Queries”

  1. Dear Ric,

    Thank you for your great video.
    How can we get the template file (.md) from you?

    Thanks a lot

    1. Hi Mahmood. I don’t supply a template for my Daily Note in its entirety as much of it is focused on my needs. The code for the Dataview queries however has been included in the article. Cheers.

  2. This is exactly what I was looking for but unfortunately I just keep getting “Dataview: No results to show for list query.”

    Not sure what I’m doing wrong. Not even trying to get fancy with the callout. Is there any ways to debug this?

    1. Without seeing your results Zack, it is a little to diagnose. That said there are really only two possibilities. If the dataview query has not been structured properly, then you will get a syntax error on screen and a caret (^) underneath the particular area of issue. It is then a matter of troubleshooting those until resolved. The second possibility is that the query is structured properly in terms of syntax, but your query is not generating data from the terms provided. This occurs when you have the FROM and WHERE statements incorrectly structured. Hope this helps. Cheers.

  3. Hey Ric,

    Im copying and pasting your code in my daily review template however its just spitting the same code back at me in the the actual daily notes file generated. Any idea what gives?

    1. Without seeing your results Zac, it is a little to diagnose. But it sounds like you are building the template and not using it. In the Daily Notes plugin, specify the template to be used and then open your daily note. It should show your template but ready to fill.

Leave a Comment

Your email address will not be published. Required fields are marked *