🖥️ How to Migrate to Obsidian Bases from Dataview


Prefer to read (or listen to) this newsletter in your browser? Click here.

Dataview has been a popular Obsidian plugin for a very long time, with over 3 million downloads since its initial release back in January of 2021.

But it's always been slow and a little tricky to use. It's also in the process of being replaced by its work-in-progress successor (Datacore), which brings additional features but a whole new syntax.

Bottom line? Now is a great time to migrate from Dataview to Obsidian Bases.

In this newsletter, I'm going to walk you through how to do it (though if you want even more detailed step-by-step instructions, check out the blog post here. It's about 3000 words and includes some code samples as well.)

The Link Between Bases & Properties

There are several different types of Properties you can use in Obsidian:

  • Text - any text characters
  • List - multiple text values stored on separate lines
  • Number - requires a numerical input
  • Checkbox - has a simple true or false state
  • Date - uses YYYY-MM-DD formatting
  • Date & Time - adds additional HH:MM formatting to a date value

These properties are the key to using Bases. You'll want to make sure that you have these configured correctly in your vault and the values are up to date before you start creating Bases views.

You can tell the type of Property by the icon next to the property name, and you can change the property type by clicking on this icon and selecting a new option from the drop-down list.

Understanding Your Current Dataview Queries

Most Dataview queries are pretty straightforward. The Dataview Query Language usually includes up to five different components that make up the query.

  1. Output
  2. Source
  3. Filter
  4. Sorting
  5. Grouping

Let's break these down before we look at how to implement them using Bases.

The first thing in a Dataview query is usually the type of output you want. There are four different kinds of output:

  • TABLE - includes rows and columns
  • LIST - similar to a table, but only shows a single column
  • TASK - shows Dataview-formatted tasks in your Obsidian vault
  • CALENDAR - shows the results in a month-view calendar

Before you can do anything else in Dataview, you must select a query type. This is the only required field for a Dataview query, and unlike Bases, you can only choose one.

Next, you need to define the source by using FROM. This tells Dataview where to pull the query from, for example, a particular tag (i.e. #project) or a specific folder in your Obsidian vault (i.e. Writing/Articles).

After you've defined the output type and the source, you need to define the filter using WHERE. This sets the conditions of the query based on the data inside your notes. Only notes where the value equals true will be displayed in the query based on the clause that you use here.

Next, you can define the order of the results rendered by the query using SORT. This determines how the results of the query will be displayed, for example, in reverse chronological order.

And lastly, you can group results together by using GROUP. This is useful if you want a secondary way of showing how things are connected.

Recreating Dataview Queries in Bases

The easiest way to recreate your Dataview queries in Bases is visually. You can either create a new .base file via the Command Palette, or you can create an inline Bases code block.

Either way, you'll get a rendered Bases query that shows all of the notes in your vault.

From here, you can start bringing over the five different Dataview query components I outlined above.

First is the output type, which in Bases is called a View. When you create a new Base, the type of output for the default view is automatically set to Table by default. You can edit the current View (or create a new view) by clicking the button in the upper-left:

Currently, there are only two view types you can choose from: Table and Cards. Table creates a table that looks very similar to the Dataview table, and the Cards view looks something like this:

(This Cards View comes from my Obsidian Book Notes Library, and if you want to see me set the whole thing up, check out this YouTube video.)

But one big advantage of Obsidian Bases is that you can actually have multiple views in the same Base. Once you create an additional view, you can apply specific filters to each and actually flip back and forth between them at will.

Next is the source (which in Dataview was defined by using FROM). This is controlled in Bases by using the Filter button. From here, you can visually build the criteria you want to use to filter the results of your Base.

When adding these, you can use a couple of conditional statements:

  • All of the following are true
  • Any of the following are true
  • None of the following are true

For each filter, you choose the property you want, the conditional statement (i.e., is, is not, contains, etc.), and the value. You can choose from any of the properties you have in your notes, as well as a bunch of inherited properties (like created or modified time).

And since you can have multiple views, you can also apply these filters for all views in the current Base or just the current view.

For example, in my Obsidian Book Notes library, I have a filter for all views that shows all notes from the Book Notes folder, then I have another view that has an additional filter that only shows books where the rating is five stars.

Being able to combine views and filters like this is really powerful, and one of the biggest advantages of using Obsidian Bases over Dataview.

When adding filters based on property values, you may want to list these values in either the Table or Cards views. To display these, click on the Properties button and just select the properties you want to make visible in the current view:

You can also edit the labels for any of these displayed Properties by clicking the carat and changing the display name.

Next, you can change the sort order of the results in your Obsidian Base by clicking the Sort button. You can sort by any of the available properties, and you can even add multiple properties here to apply different levels of sorting for larger queries.

The only thing we didn't cover yet is the grouping options from Dataview. And that's because you currently can't do anything with these in Bases. This is one area where Dataview is still better than Bases, though the public roadmap does show that grouping options are currently in development (along with List and Kanban views and even a Bases API).

Using the Dataview to Bases Converter

There's another way to convert your Dataview queries to Bases syntax by using a web tool called the Dataview to Bases converter. With this tool, you can paste your existing Dataview query in the box on the left, and the query instantly gets translated into the corresponding Bases syntax on the right:

From here, you can simply copy and paste this code into your note as an inline Bases code block that uses the same settings, sources, and filters as the original Dataview query. If you prefer, you can also download the syntax as a .base file and drop it into your Obsidian vault.

Personally, I think this tool is pretty great. If you just want a quick way to convert some of your simple Dataview queries, this free tool is perfect for you.

— Mike

Practical PKM

A weekly newsletter where I help people apply values-based productivity principles and systems for personal growth, primarily using Obsidian. Subscribe if you want to make more of your notes and ideas.

Read more from Practical PKM

📣 The Practical PKM Newsletter is changing a little bit. TL;DR - I'm going to try splitting up the content into multiple emails. You will still get the same content, just not all at once. I plan to share the Big Idea on Mondays, Something Cool on Wednesdays, and Book Notes on Fridays. As a result, today's email won't have the typical 3 sections. I plan to send a Big Idea email every week, but will likely be a little more selective about when I send the others. That way I can be a little more...

In this edition of Practical PKM: 💡 The Big Idea: A detailed look at the Personal Retreat Process 😎 Something Cool: An analog planner to help you with your Personal Retreat 📚 My book notes from How to Think Like a Roman Emperor by Donald J. Robertson Prefer to read (or listen to) this newsletter in your browser? Click here. 💡The Big Idea: Thinking Time is Critical if You Want to Make Progress on What's Important. Back when he was CEO of Microsoft, Bill Gates used to do what he called “Think...

In this edition of Practical PKM: 💡 The Big Idea: Leverage the chaos to do your best creative work 😎 Something Cool: An Obsidian plugin to add colorful properties to your Bases 📚 My book notes from Published by Chandler Bolt Prefer to read (or listen to) this newsletter in your browser? Click here. 💡 The Big Idea: Why Creativity Needs a Little Disorder Having lots of ideas shouldn’t make you feel confused. But if you’re a perfectionist like me, it often does. The urge to order and organize...