Dataview_Cheatsheet

Summary

This cheatsheet provides a handy reference guide for writing queries using Dataview Query Language (DQL) in the dataview plugin for Obsidian.md note-taking app.

How this repository came about

As I found myself frequently querying data within Obsidian, I created this cheatsheet to have quick access to the most common queries I use regularly. By adding this cheatsheet locally in Obsidian, I no longer need to leave Obsidian app and search the query syntax online.

While this cheatsheet is primarily for my own use, I'm sharing it here in case others find it useful as well. I would suggest you copy this readme and paste it in your Obsidian vault so you can search it locally just like I do.

Query Cheatsheet

Examples for very specific queries.

LIST

Simple List

LIST FROM <tag-name>

Example

LIST
FROM
#games

Table

TABLE
	Title
FROM
	#tagName

Data Commands

FROM

Selecting from different sources such as;

Tags

FROM #tag

Example

TABLE
file.cday as "Created Date"
FROM
#my-tag

Excluding notes with a specific tag

!#tag-name

Example

TABLE
	Title,
	Rating,
	Seen,
	SeenDate as "Seen on"
FROM
	#movie AND !#template

The above example will return all notes with a tag #movie but exclude notes with a tag #template. This is handy if you have a note with pre-populated tags but it's only used as a template so you don't want to see it in your table view.

Excluding notes from a specific folder

FROM #tag AND !"FolderName"

Example

TABLE
	Title,
	Rating,
	Seen,
	SeenDate as "Seen on"
FROM
	#movie AND !"TemplatesFolder"

By including !"FolderName" we specify that we do not want to return any matches if the are located in the specified folder.

Folders

FROM "folder-name"

Example

TABLE
	file.cday as "Created Date"
FROM
	"my-folder-name"

Single Files

FROM "path/to/file-name"

Example

TABLE
	file.cday as "Created Date"
FROM
	"TopFolder/SubFolder/my-file-name"

WHERE

Examples of queries containing WHERE clause.

WHERE property is NOT empty

WHERE <property-name>

Example

TABLE
	file.cday as "Created",
	Category
FROM
	#books
SORT
	file.cday
WHERE
	Category

The above example ensures to show only results where the meta-data 'Category' is not empty.

FLATTEN

Multiple properties displayed in its own row

FLATTEN <property-name>

Code example:

TABLE
	Title,
	Action
FLATTEN Action

Result example:

File Name Created Action
Note 1 July Action name 1
Note 1 July Action name 2
Note 2 August My Action 123
Note 2 August Hello World

Bool property to custom display value

Display Yes/No instead of True/False on bool properties

Snippet

CHOICE(<bool-property>, "Yes", "No") as "custom-name"

Example

TABLE
	Author as "Author",
	choice(read, "Yes", "No") as "Read",
FROM
	"Books"

Limit results in query

LIMIT 10

Example:

TABLE
	Title,
	Rating
WHERE
	Rating > 3
LIMIT 10

Meta Data Examples

Obsidian allows YAML and JSON for metadata.

JSON

JSON

{
	"Author": "Author Name",
	"Genre": "Fiction",
	"DateRead": "2022-06-01",
	"Read": false,
	"Tags": [
		"Mind-blowing",
		"Interesting",
		"Science"
	]
}

YAML

YAML

Author: Author Name
Genre: Fiction
DateRead: '2022-06-01'
Read: false
Tags:
- Mind-blowing
- Interesting
- Science