---
title: 'How to Use Obsidian Dataview: A Complete Beginners Guide'
updated: 2023-03-27 15:00:05Z
created: 2023-03-27 15:00:05Z
tags:
  - IT
  - IT/Tools/Obsidian
source: >-
  https://beingpax.medium.com/how-to-use-obsidian-dataview-a-complete-beginners-guide-2a275c274936
---

## A Non-technical Guide

![](1_sKH0yhYZc0DlfH96rjlBww_40fdcd238c804585afa79fabf.jpeg)

Obsidian dataview is one of the most widely used community plugins in obsidian. It turns your knowledge base into a database that you can query from.

If you are a non-technical person, dataview can scare you. But it doesn’t have to. This non-technical guide will help you to go from scratch to building your own database of personal knowledge in obsidian.

Using the dataview plugin in obsidian is like using obsidian on steroids. Before we begin the guide, let me show you some of the possibilities of obsidian. The setups I’ve used in my obsidian vault:

## View the most recent notes

<a id="e24c"></a>```dataview
List
From ""
Sort file.mtime DESC
Limit 5
```

It searches my entire vault and lists the recently modified 5 notes:

![](https://miro.medium.com/v2/resize:fit:295/1*UJfpZSLY_Tzl1274LdhhCQ.png)

## View notes that need to be processed

<a id="3c41"></a>```dataview
Table file.ctime as created
From #todevelop and -"008 TEMPLATES"
sort ASCE
Limit 20
```

It searches my vault with notes tagged #todevelop and lists them in ascending order excluding notes from the Templates folder. Here’s the result:

![](1_1XL70XyK1FLNhzms2KOvFg_069e62c5d25c4ccb88d3be39e.png)
This is kind of mess. Showing all the books. But you see the result.

## View books that I’m reading currently

<a id="6ba5"></a>```dataview
Table ("!\[|100\](https://beingpax.medium.com/" + cover\_url + ")") as Cover, author as Author, total\_page as "Pages", category as Category, Bar as Progress
From #book
where contains(status,"Reading")
```

It searches my vault for #book and where the status is reading. It is rendered in table format with a cover, author, pages, category, and progress bar. Here is the result:

![](https://miro.medium.com/v2/resize:fit:700/1*ORTXUK8_iflVWZAUBZY0-A.png)

Table transformed to cards using minimal theme CSS

## Reading list

Similarly, there’s another query that shows me all the books that I’ve on my reading list on my obsidian vault.

<a id="1e62"></a>```dataview
Table ("!\[|100\](https://beingpax.medium.com/" + cover\_url + ")") as Cover, author as Author, total\_page as "Pages", category as "Category"
From #book
where contains(status,"To Read")
```

![](1__oRdH--lxSuAV2t0y6WGmg_64a023b98ed04b95a98dc2683.png)
Now you’ve got a glance at what is possible with the obsidian dataview plugin, let’s learn how to use it. But before that, we need to **understand YAML.**

## What is YAML

YAML stands for Yet Another Markup Language. It is also called frontmatter which is designed to add metadata to your notes. The metadata is readable to humans as well as obsidian.

This metadata is what is used by obsidian dataview to query notes.

Metadata is the data about data. Here’s an example of metadata.

![](1_hd_hRr7Os8ahTFLcF_Z2HA_51e0fc42bf684829b875497a5.png)
Example of Metadata

Here is a video file I took from my PC. If you go to the properties and details section, everything you see is metadata. The data about this particular video. The length, resolution, bitrate, and everything. All of this is added automatically.

In obsidian also, notes have some metadata such as the creation date, and modification date that is added automatically. But if you want to create an advanced database or search queries, you have to manually add metadata to your notes.

## How to add YAML/Frontmatter?

As the name itself suggests, frontmatter should be added at the top of your notes. To add metadata, you must add three dashes in two separate lines.

<a id="f0f9"></a>\-\-\-
\-\-\-

Now everything you write in between these dashes will be metadata. For example:

<a id="390f"></a>\-\-\-
tag: book
Author: Pax
status: Reading
Rating: ⭐⭐⭐⭐⭐
\-\-\-

This is a simple example of adding metadata in markdown notes. This metadata is used by the dataview plugin for querying your vault.

Here’s an example of the YAML frontmatter of one of my book notes. We will be using book notes in my obsidian vault for examples.

![Obsidian Book Search Plugin](1_S5BDUefTAjo7pWXkL1R6Dg_3bb5552ad2ff44ea9c4cdb389.png)
Frontmatter added automatically with book search plugin

## Installing Dataview

If you haven’t installed the dataview plugin, install it from the community plugins section. Go to options and check the settings.

![](1_GM-RxcdnG1Y3mEodE4KSYw_a809033621174665b52791c4a.png)

## How to use Dataview

To use obsidian dataview you will have to start with ```(three backticks). This will create a code block. Then write dataview after three backticks.

<a id="8a3f"></a>```dataview
```

Dataview will work now. But it won’t show any result because we haven’t added any parameters.

## Different query formats available in obsidian

## List

Simply write the following code:

<a id="2116"></a>```dataview 
List
```

It will render all the notes that you have in your obsidian vault as a list.

**Result:**

![](1_Ssno2NU5AL2ozuH6HdcjUQ_d9c48d740bb1408a8e556b131.png)

## Table

The table format is similar to the list. The only difference is that it uses multiple columns.

<a id="4e48"></a>```dataview
Table
```

This will render a table but with only one column. To add columns, add this:

<a id="f3ee"></a>```dataview
Table author,category, my_rate, status
```

**Remember:** While creating table headers, the table column should be exactly the same as you have in your notes metadata(No uppercase or lowercase difference). This is the result:

![](1_IrdY38BnBR5rQOSWyvr6Lg_c593fc00e85e45d7a9b8b2070.png)
If the notes don’t have the metadata for what you specified, it will return ‘ — ’ in the table.

If you want to use a different header, use the code as follows:

<a id="67d8"></a>```dataview
Table author as Author,category as Category, my_rate as Rating, status as Status
```

![](https://miro.medium.com/v2/resize:fit:700/1*fpsD9Rvq94NdrjMw3vk2Kg.png)

The header has changed as we specified.

## Tasks

I don’t use obsidian as a task manager. But if you want to use it, the obsidian dataview plugin can become handy. Here’s the dataview code you need and how it will render:

<a id="d378"></a>```dataview  
Task
```

![](1_5x_VUe6pOqqKc_bA1tLQOA_85dabc7431f143eeb25a14773.png)
I tried to use obsidian as my content planner but abandoned it. So these are some random results.

## Calendar

The calendar dataview query will display a dot per file on the date that file was modified or created.

<a id="2f34"></a>```dataview
Calendar file.ctime
```

![](https://miro.medium.com/v2/resize:fit:700/1*HkBlZnwFEV9r_viquDa-iw.png)

The large number of dots is because I had to do the setup of my vault due to an error.

## Advanced Query (From)

I will show all of the advanced queries in a table format. Because understanding this will help you to use this in almost all other query formats.

The **from** query helps you to specify what you are looking for. Notes from a particular folder? Notes with a particular hashtag? Notes excluding a particular folder, etc.

Here’s an example of the previous table format query:

<a id="a4fe"></a>```dataview  
Table author as Author,category as Category, my_rate as Rating, status as Status  
From #book
```

This will query notes with #book only. The results?

![](1_81D-e6RqeusMY5lIBt3oRA_df104bf1d98041c3b0d51abd0.png)
If you want to **query from a particular folder**, use this: From “FOLDER_NAME”

<a id="dbf2"></a>```dataview  
Table author as Author,category as Category, my_rate as Rating, status as Status  
From "003 RESOURCES"
```

To **query from a sub-folder** use this: From “FOLDER_NAME/SUBFOLDER”

<a id="c04e"></a>From "001 PROJECTS/Twitter"

To query notes with an incoming link:

<a id="8e34"></a>From \[\[Note 1\]\]

To query notes with outgoing link:

<a id="8afc"></a>From outgoing(\[\[Note1\]\])

## Multiple queries

If you want to query a note with multiple metadata: use this

<a id="a6fb"></a>From #book and "003 RESOURCES"

This will query notes with #book and which are inside the “003 RESOURCES" folder.

<a id="6e92"></a>From #book or "003 RESOURCES"

This will query notes that either has a #book or are inside the “003 RESOURCES" folder.

To exclude particular notes you can use — sign

<a id="cf92"></a>From #book and -"008 TEMPLATES"

To conclude from queries, look this:

- **For tag:** From #tag
- **For folder or subfolder:** From “Folder”
- **For Single files:** From “path/to/file”
- **For links:** From \[\[Notes\]\]
- **For Outgoing links:** outgoing(\[\[Note\]\])

## Advanced Query(WHERE)

Where filter can be used to further improve your notes database. Let’s say I want to query the books that I’ve finished reading. Here’s how the where filter would be used:

<a id="bcea"></a>```dataview  
Table author as Author,category as Category, my_rate as Rating, status as Status  
From #book and -"008 TEMPLATES"
Where contains(status,"Completed")
```

Look at the metadata I’ve in my book notes for reference in “How to add YAML section?”

Here’s how the query result will appear:

![](1_qcT_F77IBZCFHCHf5I6dfA_ab33326df75442b88559e99f1.png)
Note: The notes in your metadata are used for all the queries. If you don’t have proper data, it will cause errors.

Let’s say you want to exclude all the notes that contain completed status. To do that you need to add the ‘!’ mark before contains like this:

<a id="5b0d"></a>```dataview  
Table author as Author,category as Category, my_rate as Rating, status as Status  
From #book and -"008 TEMPLATES"
Where !contains(status,"Completed")
```

This will exclude notes that contain completed status:

![](https://miro.medium.com/v2/resize:fit:700/1*nMYt4U8-3cGsMTsyIJrUMw.png)

**Another example:**

Find the notes that you created recently. This will list the notes that have been created in the last 1 day.

<a id="fd6b"></a>```dataview 
List
From ""
Where file.ctime >= date(today) - dur(1 day)
```

## Sort your notes

There is another great community plugin called sortable. It allows you to sort your database without editing it every time you want to sort it. If you don’t want to use it, you can use the code as well:

<a id="3666"></a>```dataview  
Table author as Author,category as Category, my_rate as Rating, status as Status  
From #book and -"008 TEMPLATES"
Where contains(status,"Completed")
Sort file.mtime DESC

This will sort the files according to their modified time. You can use different other metadata too. For example, I’ve book notes in my vault and they also have metadata for no. of pages. I can sort them by pages using the dataview code:

<a id="09de"></a>```dataview    
Table author as Author,category as Category, my\_rate as Rating, status as Status, total\_page as Pages   
From #book and -"008 TEMPLATES"  
Where contains(status,"Completed")  
Sort total_page Asc
```

![](https://miro.medium.com/v2/resize:fit:700/1*PBKdTlvA3Bbp8kdAMAsjfw.png)

## Limit the queries

You may have a lot of notes in your vault. If you don’t want to see all of your notes. If you want to **restrict the results to a particular number** you can use the limit function.

<a id="75b3"></a>```dataview    
Table author as Author,category as Category, my\_rate as Rating, status as Status, total\_page as Pages   
From #book and -"008 TEMPLATES"  
Where contains(status,"Completed")  
Sort total_page Asc
Limit 7
```

**The result?**

![](1_NsjQfeIgCAkUxDoRT6p1Dg_07439e8a299b419b922f7041b.png)
No. of queries limited to 7

The obsidian dataview plugin is simple. **Don’t let the large setups scare you.** Start with simple dataview queries like a list or table. Then slowly start using other dataview functions as required.

![Prakash Joshi Pax](1_g0R0rdMNO-IFOlmVIYEJLQ_d4813e09e1f54e5ca29384c9b.png)

## Obsidian Note-Taking

## Not a Medium Member Yet?

If you liked this story, you will love the [**medium subscription**](https://beingpax.medium.com/membership). With only *$5 a month*(less than the price of a cup of coffee), you get unlimited access to the best stories and articles written on the web.

This is [***my referral link***](https://beingpax.medium.com/membership)*.* If you sign up using this link, I earn a small commission with no additional charges to you.